1. Prepare the Server
Order a VPS with Ubuntu 24.04 and secure it. At your DNS provider, add an A record for example.com (and www) with the server's IP address, so the certificate step works later.
2. Install Nginx, PHP and MariaDB
sudo apt update sudo apt install -y nginx mariadb-server \ php8.3-fpm php8.3-mysql php8.3-curl php8.3-xml php8.3-mbstring \ php8.3-zip php8.3-gd php8.3-intl sudo ufw allow 'Nginx Full' sudo mysql_secure_installation # answer yes to the security questions
3. Create the Database
sudo mariadb <<'SQL' CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'a-long-random-password'; GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress'@'localhost'; FLUSH PRIVILEGES; SQL
Use a long random password of your own and keep it for the next step.
4. Download WordPress
cd /tmp wget https://wordpress.org/latest.tar.gz tar -xzf latest.tar.gz sudo mv wordpress /var/www/example.com sudo cp /var/www/example.com/wp-config-sample.php /var/www/example.com/wp-config.php sudo chown -R www-data:www-data /var/www/example.com
In /var/www/example.com/wp-config.php, set DB_NAME, DB_USER and DB_PASSWORD to the values from step 3, and leave DB_HOST as localhost. Replace the block of put your unique phrase here lines under "Authentication unique keys and salts" with fresh ones from WordPress's generator:
curl -s https://api.wordpress.org/secret-key/1.1/salt/
5. Add the Nginx Site
In /etc/nginx/sites-available/example.com:
server {
listen 80;
server_name example.com www.example.com;
root /var/www/example.com;
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;
}
}sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/ sudo nginx -t && sudo systemctl reload nginx
The try_files line gives WordPress its pretty permalinks. For uploads above PHP's default limit, also raise upload_max_filesize and post_max_size in /etc/php/8.3/fpm/php.ini and restart php8.3-fpm.
6. Turn On HTTPS and Run the Installer
sudo apt install -y certbot python3-certbot-nginx sudo certbot --nginx -d example.com -d www.example.com
Certbot adds the certificate to the server block and renews it on a timer. If validation fails, see fixing Certbot validation errors. Then open https://example.com, pick a language, enter the site title and an administrator account (not named "admin"), and sign in.
7. Email, Updates and Backups
- Email: outgoing port 25 is blocked on every VPS, so password resets and contact forms need an SMTP plugin set to your mail provider on port 587 or 465. See sending email from your server.
- Updates: keep WordPress, plugins and themes current from Dashboard → Updates, turn on automatic updates for plugins you trust, and remove the ones you do not use.
- Backups: a site is its folder plus its database. Dump the database nightly and copy both off the server, as in backing up a database to S3, or to a storage box.
mkdir -p ~/backups sudo mariadb-dump --single-transaction wordpress | gzip > ~/backups/wordpress-$(date +%F).sql.gz
Moving an existing site from shared hosting? Follow moving from shared hosting to a VPS, and for more than one site on the server, see how many websites a VPS can host.