WordPress is the world’s most popular CMS, powering over 40% of all websites. This guide deploys a fresh WordPress installation on Ubuntu 24.04 LTS using Nginx, PHP 8.3-FPM, and MySQL 8.0.

Tested and valid on:

  • Ubuntu 24.04 LTS

Prerequisites

  • Ubuntu 24.04 LTS server
  • Nginx, PHP 8.3-FPM, MySQL 8.0 installed
  • A domain name pointed to your server
  • Certbot installed

Step 1 – Create a MySQL Database

Create the WordPress database and user:

sudo mysql
CREATE DATABASE wordpress;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'WpStrongPass123!';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Step 2 – Download WordPress

Download and extract the latest WordPress:

cd /tmp && curl -LO https://wordpress.org/latest.tar.gz
tar xzf latest.tar.gz
sudo mv wordpress /var/www/mysite.com

Step 3 – Set Permissions

Assign ownership to www-data:

sudo chown -R www-data:www-data /var/www/mysite.com
sudo find /var/www/mysite.com -type d -exec chmod 755 {} ;
sudo find /var/www/mysite.com -type f -exec chmod 644 {} ;

Step 4 – Configure WordPress

Copy the sample config and add database credentials:

cd /var/www/mysite.com
sudo cp wp-config-sample.php wp-config.php
sudo nano wp-config.php

Set:

define( 'DB_NAME', 'wordpress' );
define( 'DB_USER', 'wpuser' );
define( 'DB_PASSWORD', 'WpStrongPass123!' );
define( 'DB_HOST', 'localhost' );

Step 5 – Create the Nginx Server Block

Create a WordPress-optimised Nginx config:

sudo nano /etc/nginx/sites-available/mysite.com

Add:

server {
    listen 80;
    server_name mysite.com www.mysite.com;
    root /var/www/mysite.com;
    index index.php;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ .php$ {
        fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /.ht { deny all; }
}

Enable and reload:

sudo ln -s /etc/nginx/sites-available/mysite.com /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx

Step 6 – Add SSL with Certbot

Secure WordPress with HTTPS:

sudo certbot --nginx -d mysite.com -d www.mysite.com

Step 7 – Complete the WordPress Install

Visit https://mysite.com and complete the 5-step web installer to set the site title, admin user, and password.

Conclusion

WordPress is now running on Ubuntu 24.04 LTS with Nginx and PHP 8.3-FPM. Keep WordPress, themes, and plugins updated regularly. Consider installing a caching plugin such as WP Rocket or W3 Total Cache for performance.