How to Install WordPress on a VPS

Web Hosting 3 min read Updated June 2026

This guide walks you through installing WordPress on a VPS running Ubuntu 22.04 with Nginx, MySQL, and PHP (the LEMP stack) - so you can self-host WordPress with full control over your data.

Prerequisites

Step 1: Install Required Software

Install PHP, MySQL, and required extensions:

apt update
apt install mysql-server php8.1-fpm php8.1-mysql php8.1-xml php8.1-mbstring php8.1-curl php8.1-zip php8.1-gd unzip -y

Step 2: Configure MySQL

Secure your MySQL installation:

mysql_secure_installation

Follow the prompts to set a root password and remove test databases.

Now create a database and user for WordPress:

mysql -u root -p

Inside the MySQL prompt:

CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'StrongPassword123!';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Step 3: Download WordPress

cd /tmp
wget https://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz
cp -r wordpress /var/www/mywordpresssite
chown -R www-data:www-data /var/www/mywordpresssite
chmod -R 755 /var/www/mywordpresssite

Step 4: Configure WordPress

Copy the sample config file:

cp /var/www/mywordpresssite/wp-config-sample.php /var/www/mywordpresssite/wp-config.php
nano /var/www/mywordpresssite/wp-config.php

Update these lines with your database details:

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

Also update the secret keys by visiting: https://api.wordpress.org/secret-key/1.1/salt/ and replacing the placeholder block in the config.

Step 5: Configure Nginx for WordPress

Create an Nginx server block:

nano /etc/nginx/sites-available/wordpress

Paste:

server {
    listen 80;
    server_name yourdomain.com www.yourdomain.com;
    root /var/www/mywordpresssite;

    index index.php index.html;

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

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php8.1-fpm.sock;
    }

    location ~ /\.ht {
        deny all;
    }
}

Enable and reload:

ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/
nginx -t
systemctl reload nginx

Step 6: Complete the WordPress Setup

Visit your domain in a browser:

http://yourdomain.com

You'll see the WordPress installation wizard. Enter:

Click Install WordPress. Done!

Secure your site with a free SSL certificate:

apt install certbot python3-certbot-nginx -y
certbot --nginx -d yourdomain.com -d www.yourdomain.com

Follow the prompts and your site will be automatically configured for HTTPS. For a full walkthrough, see Set up HTTPS (SSL).

Useful Tips


Questions? Email us at [email protected] - we reply in under 2 hours, 7 days a week.

Top up in crypto.
Be root in a minute.

No cards. No KYC. Uninterrupted service since 2014. For people who'd rather not explain why they need a server.

Deploy a server →