You have a VPS. Now you want to install WordPress. But where do you start?

This guide walks you through every step. No prior experience needed. I'll assume you have a VPS running Ubuntu 24.04.

What You'll Need

Before starting, make sure you have:

  • A VPS with Ubuntu 24.04 installed (check our VPS reviews if you don't have one)
  • SSH access to your server (username and password or SSH key)
  • A domain name pointed to your VPS (optional for testing)
  • About 30 minutes of time

Step 1: Connect to Your VPS via SSH

Open your terminal (Mac/Linux) or PowerShell (Windows 10/11).

ssh username@your_server_ip

Enter your password when prompted. You should see a welcome message and a command prompt.

Step 2: Update Your Server

Always start with a fresh system. Run these commands:

sudo apt update
sudo apt upgrade -y

This updates all existing software to the latest versions. The -y flag automatically answers "yes" to prompts.

Step 3: Install Nginx (Web Server)

We'll use Nginx because it's fast and easy to configure.

sudo apt install nginx -y

After installation, check that Nginx is running:

sudo systemctl status nginx

You should see "active (running)" in green. Open your browser and visit your server's IP address. You should see the default Nginx welcome page.

Step 4: Install MySQL (Database)

WordPress needs a database to store content.

sudo apt install mysql-server -y

After installation, run the security script:

sudo mysql_secure_installation

Answer the questions. Set a root password when asked. Remove anonymous users, disable remote root login, remove test databases. These are all good for security.

Now create a database for WordPress:

sudo mysql -u root -p

Enter your MySQL root password. Then run these SQL commands:

CREATE DATABASE wordpress_db;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'your_strong_password';
GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Write down the database name (wordpress_db), username (wpuser), and password. You'll need them later.

Step 5: Install PHP

WordPress requires PHP. We'll install PHP 8.2 with common extensions.

sudo apt install php8.2-fpm php8.2-mysql php8.2-cli php8.2-curl php8.2-gd php8.2-mbstring php8.2-xml php8.2-zip -y

These extensions handle everything WordPress needs – images, curl requests, zip files, etc.

Check that PHP is working:

php -v

Step 6: Configure Nginx for WordPress

Create a new Nginx configuration file for your site:

sudo nano /etc/nginx/sites-available/wordpress

Paste this configuration. Replace `your_domain.com` with your actual domain or IP address.

server {
    listen 80;
    server_name your_domain.com;
    root /var/www/wordpress;
    index index.php index.html;

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

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

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

Save and exit (Ctrl+X, then Y, then Enter).

Enable the site and test the configuration:

sudo ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/
sudo nginx -t

If the test passes, reload Nginx:

sudo systemctl reload nginx

Step 7: Download WordPress

Create the web root directory and download WordPress:

sudo mkdir -p /var/www/wordpress
cd /var/www/wordpress
sudo wget https://wordpress.org/latest.tar.gz
sudo tar -xzf latest.tar.gz --strip-components=1
sudo rm latest.tar.gz

Set the correct permissions:

sudo chown -R www-data:www-data /var/www/wordpress
sudo chmod -R 755 /var/www/wordpress

Step 8: Configure WordPress

Copy the sample config file and edit it:

sudo cp wp-config-sample.php wp-config.php
sudo nano wp-config.php

Find these lines and fill in your database details from Step 4:

define( 'DB_NAME', 'wordpress_db' );
define( 'DB_USER', 'wpuser' );
define( 'DB_PASSWORD', 'your_strong_password' );
define( 'DB_HOST', 'localhost' );

Save and exit.

Step 9: Complete WordPress Installation in Your Browser

Open your browser and visit your server's IP address or domain.

You should see the WordPress setup wizard. Select your language, then click Continue.

Fill in your site title, admin username, admin password, and email address. Choose a strong password – this is your admin account.

Click Install WordPress. After a few seconds, you'll see the success message. Click Log In to access your WordPress admin dashboard.

Step 10: Next Steps

Your WordPress site is now live. Here's what to do next:

  • Change your permalink structure to "Post name" (Settings → Permalinks)
  • Install a security plugin like Wordfence or Solid Security
  • Set up regular backups
  • Install an SSL certificate (use Certbot for free HTTPS)

To add SSL, run:

sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d your_domain.com

Troubleshooting

"502 Bad Gateway" error
PHP-FPM is not running. Check with `sudo systemctl status php8.2-fpm` and start it if needed.

"Connection refused" when accessing the site
Nginx may not be running. Check with `sudo systemctl status nginx`. Also verify your firewall allows port 80 and 443.

"Error establishing database connection"
Your database credentials are wrong or MySQL isn't running. Check the credentials in wp-config.php and run `sudo systemctl status mysql`.

Need a VPS to practice on? Check our recommended VPS providers.