WordPress on a VPS: nginx, PHP, MariaDB and HTTPS
Shared hosting is fine until a neighbour's site eats the CPU or you need a PHP extension the host won't install. On a VPS the whole stack is yours. This guide sets up WordPress on Ubuntu 24.04 with nginx, PHP 8.3, MariaDB and a free Let's Encrypt certificate. It takes about 20 minutes.
Which plan
For one site with moderate traffic, Pulse (2 vCPU, 2 GB RAM, $10/month) is the comfortable minimum. MariaDB and PHP-FPM together want around 600–800 MB, and WooCommerce with a few thousand products wants more.
Point your domain's A record at the server's IP before you start. The certificate step needs it.
1. Packages
apt update && 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 php-imagick
2. Database
mysql -e "CREATE DATABASE wp DEFAULT CHARACTER SET utf8mb4;
CREATE USER 'wp'@'localhost' IDENTIFIED BY 'change-this-password';
GRANT ALL ON wp.* TO 'wp'@'localhost'; FLUSH PRIVILEGES;"
3. WordPress files
cd /var/www && curl -sO https://wordpress.org/latest.tar.gz
tar xzf latest.tar.gz && rm latest.tar.gz
chown -R www-data:www-data /var/www/wordpress
4. nginx
/etc/nginx/sites-available/wordpress (replace example.com):
server {
listen 80;
server_name example.com www.example.com;
root /var/www/wordpress;
index index.php;
client_max_body_size 64m;
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 ~ /\.(?!well-known) { deny all; }
}
ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/
rm /etc/nginx/sites-enabled/default
nginx -t && systemctl reload nginx
5. HTTPS
apt install -y certbot python3-certbot-nginx
certbot --nginx -d example.com -d www.example.com
Certbot edits the nginx config and renews the certificate on its own. Now open https://example.com and finish the installer: database wp, user wp, the password from step 2.
After the install
- Raise the PHP upload limit if you upload large media: set
upload_max_filesizeandpost_max_sizein/etc/php/8.3/fpm/php.ini, thensystemctl restart php8.3-fpm. - Mail. Sending email straight from a fresh server IP usually lands in spam. Send WordPress mail through an SMTP service with a plugin like WP Mail SMTP.
- Backups are on you. Dump the database (
mysqldump wp > wp.sql) and copywp-contentsomewhere off the server on a schedule. A backup that lives on the same server isn't a backup. - Updates.
apt upgradefor the system, the WordPress dashboard for core and plugins. Outdated plugins are how most WordPress sites get hacked.
If the site outgrows Pulse, we move it to a larger plan on request, usually without reinstalling.