Install WordPress on an Ubuntu VPS with Nginx and MariaDB
Production-ready WordPress on Ubuntu 24.04: Nginx, PHP 8.3 FPM, MariaDB, Let's Encrypt. The whole stack in under thirty minutes.

WordPress runs millions of sites and most of them are slow because someone clicked "1-click install" on a shared host. A VPS with a hand-rolled stack is faster, cheaper at scale, and yours to tune. Here's the install that actually holds up.
The stack
- Ubuntu 24.04 LTS
- Nginx as the web server
- PHP 8.3 FPM
- MariaDB 11
- Let's Encrypt via Certbot
Run a baseline server hardening first (see the initial setup guide) before continuing.
Install the packages
sudo apt update
sudo apt install -y nginx mariadb-server php8.3-fpm php8.3-mysql \
php8.3-curl php8.3-gd php8.3-intl php8.3-mbstring php8.3-xml \
php8.3-zip php8.3-imagick unzip
Verify each service is running:
systemctl status nginx mariadb php8.3-fpm
Database setup
Lock down MariaDB first:
sudo mariadb-secure-installation
Answer "yes" to everything except switching to unix_socket auth (your call). Then create the WordPress database and user:
sudo mariadb <<'SQL'
CREATE DATABASE wordpress CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wp'@'localhost' IDENTIFIED BY 'pick-a-strong-password';
GRANT ALL ON wordpress.* TO 'wp'@'localhost';
FLUSH PRIVILEGES;
SQL
Drop in WordPress
sudo mkdir -p /var/www/example.com
cd /tmp && curl -O https://wordpress.org/latest.tar.gz
sudo tar xf latest.tar.gz -C /var/www/example.com --strip-components=1
sudo chown -R www-data:www-data /var/www/example.com
Nginx server block
Create /etc/nginx/sites-available/example.com:
server {
listen 80;
listen [::]:80;
server_name example.com www.example.com;
root /var/www/example.com;
index index.php;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
}
location ~ /\.ht { deny all; }
client_max_body_size 64m;
}
Enable and reload:
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
HTTPS via Certbot
DNS must point at your VPS first. Then:
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo certbot --nginx -d example.com -d www.example.com
See the Nginx + Let's Encrypt guide for hardening the TLS config to A+.
Finish in the browser
Visit https://example.com. WordPress's installer prompts for the database details you created above. Five minutes of clicking and you have a site.
Tuning that actually matters
- PHP OPcache is on by default in PHP 8.3. Verify with
php8.3 -i | grep opcache.enable. - Object cache Install Redis (
apt install redis-server) and the Redis Object Cache plugin. Massive admin-side speedup. - Page cache WP Super Cache or LiteSpeed Cache (yes it works on Nginx) to serve static HTML where possible.
- No plugin diet. Most slow WordPress sites are slow because of plugins, not hosting. Audit before you scale up the VPS.
That's a working WordPress install. Hand-tuned, repeatable, and roughly 1/10 the price of "managed WordPress" hosting once you can read an Nginx log.
Continue reading