India English
Kenya English
United Kingdom English
South Africa English
Nigeria English
United States English
United States Español
Indonesia English
Bangladesh English
Egypt العربية
Tanzania English
Ethiopia English
Uganda English
Congo - Kinshasa English
Ghana English
Côte d’Ivoire English
Zambia English
Cameroon English
Rwanda English
Germany Deutsch
France Français
Spain Català
Spain Español
Italy Italiano
Russia Русский
Japan English
Brazil Português
Brazil Português
Mexico Español
Philippines English
Pakistan English
Türkiye Türkçe
Vietnam English
Thailand English
South Korea English
Australia English
China 中文
Canada English
Canada Français
Somalia English
Netherlands Nederlands

How to Install WordPress on a New Virtual Private Server

Buy domains, business emails, hosting, VPS and more: Get Started

You just checked out on a new VPS plan. The confirmation email is sitting in your inbox. Now you have an IP address, a root password, and nothing else on the server.

No dashboard, installer button, or safety net.

This is the point where a lot of people get stuck. One wrong command can leave a half-working server or a database that never connects to WordPress at all.

Skip a permission fix, and you get a blank white screen with zero explanation.

This guide walks you through the full path, from a bare server to a working WordPress login screen.

Each step below is written for a real Ubuntu 24.04 VPS so that you can follow along in your own terminal.

What You Need Before You Start

Best VPS Hosting deals ever

Before you touch the terminal, confirm a few basics so the rest of the setup goes smoothly.

  • A VPS with root or sudo access, running Ubuntu 24.04 LTS
  • At least 1 vCPU, 10 GB SSD storage, and 1GB of RAM as a working floor for a small WordPress site
  • An SSH client, such as PuTTY on Windows or the built-in Terminal app on macOS and Linux
  • A registered domain name, though you can test with the raw IP first
  • Your VPS provider login, in case you need to check firewall or network settings later

Once these are in place, you are ready to connect.

1) Connect to Your VPS via SSH

using windows terminal to ssh to a vps

SSH is how you talk to your server from your own computer. Open your terminal and type this, replacing the placeholders with your own details:

ssh root@your_server_ip

The first time you connect, your terminal will ask you to confirm the server’s fingerprint. Type yes and press enter.

Once connected, you are logged in as root. Root has full access to everything on the server, so it carries real risk if a command goes wrong.

Create a new user with sudo privileges instead, and switch to that account for daily work:

adduser yourusername
usermod -aG sudo yourusername
su - yourusername

Confirm the new user works by running a simple command like whoami before moving forward.

2) Update the Server and Install the LEMP Stack

WordPress needs a small stack of software to run: a web server, a database, and PHP. This guide uses Nginx, MySQL, and PHP, known together as the LEMP stack.

Start by updating the package list and installed software:

sudo apt update && sudo apt upgrade -y

Then install Nginx:

sudo apt install nginx -y

Nginx handles web traffic with a lighter footprint than Apache, which helps on smaller VPS plans.

Next, install MySQL and run the built-in security script:

sudo apt install mysql-server -y
sudo mysql_secure_installation

Answer yes to the prompts about removing test databases and disabling remote root login. These steps close off common attack paths early.

Now install PHP along with the extensions WordPress needs:

sudo apt install php-fpm php-mysql php-curl php-xml php-mbstring php-zip -y

At this point, your server has everything it needs to run WordPress. The next step is setting up a database for it.

3) Create the WordPress Database and User

Log in to MySQL as root:

sudo mysql

Then create a database, a user, and grant that user access. Replace the placeholder values with your own:

CREATE DATABASE wordpress_db;

CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'your_strong_password';

GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wp_user'@'localhost';

FLUSH PRIVILEGES;

EXIT;

Pick a database prefix other than the default wp_ later in the setup screen. This small change adds a layer of protection against automated attacks that target default table names.

4) Download and Configure WordPress

download wordpress package and install on vps

Move to a working directory and pull down the latest WordPress files:

cd /tmp

wget https://wordpress.org/latest.tar.gz

tar -xzvf latest.tar.gz

Copy the extracted files into your website directory:

sudo cp -a /tmp/wordpress/. /var/www/html/

Fix ownership so Nginx and PHP can read and write the files properly:

sudo chown -R www-data:www-data /var/www/html

sudo chmod -R 755 /var/www/html

Skipping this step is a common cause of the “directory is not writable” error, so do not skip it.

Now, rename and edit the config file:

cd /var/www/html

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

sudo nano wp-config.php

Enter your database name, username, and password from the previous step.

Then visit the WordPress salt key generator online, copy the output, and paste it to replace the placeholder keys. Save and exit with Ctrl+X, then Y.

5) Configure Nginx for WordPress

Nginx needs a server block that specifies where to find your WordPress files and how to handle PHP requests.

Create a new config file:

sudo nano /etc/nginx/sites-available/yourdomain.com

Paste in a block like this, adjusting the domain and PHP version as needed:

server {

    listen 80;

    server_name yourdomain.com www.yourdomain.com;

    root /var/www/html;

    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.3-fpm.sock;

    }

}

Enable the site and remove the default one:

sudo ln -s /etc/nginx/sites-available/yourdomain.com /etc/nginx/sites-enabled/

sudo rm /etc/nginx/sites-enabled/default

Test the config before reloading, so a typo does not take down the whole server:

sudo nginx -t

sudo systemctl reload nginx

A blank page or a 502 error at this stage usually indicates a mismatched PHP socket path in this file.

6) Point Your Domain and Run the Web Installer

Log in to your domain registrar and update the A record to point at your VPS IP address. This step often takes a few hours to spread across the internet, so patience helps here.

Once the domain resolves, or if you are testing with the raw IP, open a browser and visit it. You should see the WordPress welcome screen.

Follow the prompts on screen:

  • Pick your language
  • Set your site title
  • Choose an admin username that is not “admin”
  • Set a strong admin password
  • Enter your email address

Click Install WordPress, and your site is live.

7) Secure and Harden the Installation

A fresh install is functional, but not locked down yet. A few steps here go a long way.

Install a free SSL certificate with Certbot, so traffic between your visitors and your server stays encrypted:

sudo apt install certbot python3-certbot-nginx -y

sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com

Certbot will ask for an email and offer to redirect all traffic to HTTPS. Choose the redirect option.

Next, set up a firewall so only the ports you actually need stay open:

sudo ufw allow OpenSSH
sudo ufw allow 'Nginx Full'
sudo ufw enable

Inside the WordPress dashboard, disable file editing from the admin area by adding this line to wp-config.php:

define('DISALLOW_FILE_EDIT', true);

Finally, set up automated backups for both your database and your files, and store copies off the server.

A cron job that runs mysqldump on a schedule works well for this, paired with a backup plugin or a script that archives the wp-content folder.

Common Errors and How to Fix Them

ErrorLikely CauseFix
502 Bad GatewayNginx cannot reach PHP-FPM, often due to a wrong socket pathCheck the fastcgi_pass line in your Nginx config, confirm the PHP-FPM version matches, then run sudo systemctl restart php8.3-fpm nginx
504 Gateway TimeoutPHP-FPM is running, but taking too long to respondRaise fastcgi_read_timeout in your Nginx config and check for a slow plugin or query once the site loads
Error establishing a database connectionWrong credentials in wp-config.php, or MySQL is not runningRecheck the database name, user, and password, then run sudo systemctl status mysql to confirm the service is active
Directory not writable / permission deniedFile ownership was not set correctly after copying WordPress filesRun sudo chown -R www-data:www-data /var/www/html and sudo chmod -R 755 /var/www/html again
White screen with no error messageA plugin or theme conflict, or a low PHP memory limitAdd define('WP_MEMORY_LIMIT', '256M'); to wp-config.php, and rename the plugins folder to test
403 ForbiddenMissing index file, or Nginx root path pointing to the wrong folderConfirm the root directive in your Nginx config matches where WordPress actually lives
404 error on every post or pagePermalinks were never saved, or the Nginx try_files block is missingGo to Settings, Permalinks, and click Save, then confirm the try_files line sits inside your Nginx config
SSH connection refusedThe VPS firewall is blocking port 22, or the service is not runningCheck your provider’s network panel, then run sudo systemctl status ssh from the console if you can reach it another way
SSL certificate fails to issueDNS has not finished pointing at the server yetWait for DNS to propagate fully, then rerun sudo certbot --nginx -d yourdomain.com
Access denied for MySQL userA typo in the username or password used during database setupLog back into MySQL as root and reset the password with ALTER USER 'wp_user'@'localhost' IDENTIFIED BY 'new_password';

How to Go About It

Even with every step followed closely, something can still go wrong. The table above is a quick reference for the most common errors during a manual VPS install.

Check the Nginx error log at /var/log/nginx/error.log first whenever a fix does not line up with the symptom. It usually points straight at the real cause.

FAQs

Can I install WordPress on a VPS without cPanel?

How much RAM does a VPS need to run WordPress?

Is it hard to install WordPress manually on a VPS?

Can I use a one-click installer instead of the manual method?

How long does it take to install WordPress on a VPS?

Set Up WordPress on VPS Today

A manual install takes more typing than a one-click button, but it hands you full control over every layer of your stack. You know exactly what software is running, what ports are open, and how your files are structured.

Before you add a single theme or plugin, run back through your setup. Confirm HTTPS is active, check that your permalinks work under Settings, and confirm your backup job actually ran once.

Once that checklist is clear, your next stop should be tuning your new server for speed, since a fresh WordPress install on a VPS still has real room to improve with caching and PHP tuning.

Elias N
Author

Elias N

SEO Expert Nairobi, KEN

SEO nerd by trade. Obsessing over keywords, content, and why Google does what it does.

View All Posts