Hosting · Guide
How to Set Up WordPress on a VPS

Short answer
To set up WordPress on a VPS, install Nginx, MySQL and PHP on Ubuntu, create a database and user, download WordPress with WP-CLI, point an Nginx server block at the WordPress folder, and add HTTPS with Certbot. Allow one to two hours for a first install, and start with at least 1 GB of RAM.
Key takeaways
- WordPress.org recommends PHP 8.3 or newer, MariaDB 10.11 or newer or MySQL 8.4 or newer, and HTTPS support.
- Start with at least 1 GB of RAM for a live site, and 2 GB if the site takes orders or gets steady traffic.
- WP-CLI installs WordPress with four commands: core download, config create, db create and core install.
- Let's Encrypt certificates last 90 days, and Certbot renews them automatically with a twice-daily timer.
- Check the install in Tools, then Site Health, and confirm the PHP version is 8.3 or newer.
What do you need before you start?
You need a VPS with SSH access, a domain name pointed at the server, and about one to two hours for a first install.
A VPS is a virtual server you rent by the month, and you control the whole software stack on it. That control is the point of this guide, and it is also the work: there is no hosting panel that installs WordPress for you.
Gather these four things before you touch the server:
- A VPS running Ubuntu 24.04 LTS, which Canonical supports with standard security maintenance until May 2029, according to Ubuntu's release cycle page.
- A domain name, with access to its DNS records so you can point it at the server IP.
- An SSH client, such as Terminal on Mac or Linux, or Windows Terminal on Windows.
- The WordPress requirements: WordPress.org's Requirements page recommends PHP 8.3 or newer, MariaDB 10.11 or newer or MySQL 8.4 or newer, and HTTPS support (checked November 2026).
If you are still deciding whether a VPS is the right fit, read what a VPS is first. A managed plan or shared hosting suits most small sites better, and a VPS pays off when you want full control or your site has outgrown shared limits.
How do you pick the right VPS size?
Pick at least 1 GB of RAM for a small live site, and 2 GB if the site takes orders or gets steady traffic.
Memory matters more than CPU for WordPress, because PHP and MySQL both hold data in RAM. A server that runs out of memory starts swapping to disk, and pages slow down fast.
DigitalOcean lists its Basic Droplets from $4 a month as of November 2026, on its Droplet pricing page:
| Plan | RAM | vCPUs | Disk | Price per month |
|---|---|---|---|---|
| Basic | 512 MiB | 1 | 10 GiB | $4 |
| Basic | 1 GiB | 1 | 25 GiB | $6 |
| Basic | 2 GiB | 1 | 50 GiB | $12 |
| Basic | 4 GiB | 2 | 80 GiB | $24 |
Skip the 512 MiB plan for a live site. It leaves too little room for PHP, MySQL and Nginx at once. Start with the 2 GiB plan at $12 a month if the budget allows, since it gives MySQL room to cache and leaves headroom for traffic spikes.
Other providers sell similar sizes at similar prices, so compare RAM first and price second. The comparison in shared vs VPS vs managed WordPress hosting explains when each type makes sense.
How do you connect to your VPS and lock it down?
Connect over SSH as a user with sudo rights, then open only the ports your site needs.
Your provider shows the server IP address in its dashboard after the VPS is created. Connect from your own computer with this command, using the username your provider gave you:
ssh username@server_ip_address
Work as a normal user with sudo rights, not as root. Running every command as root means one typo can damage the whole system, and a stolen root login gives an attacker full control.
Turn on the firewall before you install anything. Allow SSH (port 22) and web traffic (ports 80 and 443), then enable it. On Ubuntu, the built-in firewall tool is UFW, and the rule names are OpenSSH and Nginx Full.
Check the connection works before moving on. If SSH fails, fix it now, because every later step needs it. Note the server IP and your login details somewhere safe, since you will use them through the whole install.
How do you install the LEMP stack?
Install Nginx, MySQL and PHP-FPM, plus the PHP extensions WordPress needs.
LEMP stands for Linux, Nginx, MySQL and PHP. Nginx serves pages, MySQL stores content, and PHP runs WordPress. DigitalOcean's LEMP tutorial for Ubuntu 22.04 walks through the same stack this guide uses.
Update the package list first, then install the stack:
sudo apt update
sudo apt install nginx mysql-server php-fpm php-mysql
Then add the PHP extensions WordPress and its plugins use most:
sudo apt install php-curl php-gd php-intl php-mbstring php-soap php-xml php-xmlrpc php-zip
That extension list comes from DigitalOcean's LEMP tutorial, and it covers image handling, text processing and remote requests. Restart PHP-FPM after installing them so the new extensions load:
sudo systemctl restart php8.3-fpm
Check the exact PHP version on your server with php -v, since the service name follows the version. On Ubuntu 24.04 the packaged PHP version is 8.3, which meets the WordPress.org requirement of PHP 8.3 or newer.
How do you create the WordPress database?
Create one database and one user that only has access to that database.
WordPress keeps every post, page, user and setting in MySQL or MariaDB. A dedicated database user limits the damage if one site is ever compromised, so never let WordPress log in as the MySQL root user.
Log in to MySQL as root and create the database:
sudo mysql
CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
Then create the user, give it full rights on that database only, and exit:
CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'a-strong-password-here';
GRANT ALL ON wordpress.* TO 'wordpressuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Pick a long random password and store it in a password manager. You will type it once more when WordPress asks for its database details, and after that you should not need it day to day.
How do you install WordPress with WP-CLI?
WP-CLI downloads WordPress and finishes the install with four short commands.
WP-CLI is the official command-line tool for WordPress, maintained on make.wordpress.org. It replaces the browser installer and makes repeat installs fast.
First, install WP-CLI itself:
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
Then move to your web folder and download WordPress:
cd /var/www/wordpress
wp core download
Next, create the config file with the database details from the last step:
wp config create --dbname=wordpress --dbuser=wordpressuser --prompt=dbpass
The --prompt=dbpass flag asks for the password without writing it into your shell history. Then create the database tables entry and run the install:
wp db create
wp core install --url=example.com --title="Your Site Title" --admin_user=admin --admin_password=your-admin-password [email protected]
Use your real domain in place of example.com. The install command creates the admin account, so choose a username other than admin and a strong password.
How do you point Nginx at WordPress?
Point an Nginx server block at your WordPress folder and set the file owner to www-data.
A server block tells Nginx which folder to serve for your domain. Create the file /etc/nginx/sites-available/example.com and set its root to your WordPress folder, using your own domain name in place of example.com.
The key line inside the location / block sends requests WordPress cannot match as files to index.php:
try_files $uri $uri/ /index.php$is_args$args;
That line is what makes pretty permalinks work, and it comes from DigitalOcean's LEMP tutorial for Ubuntu 22.04.
Link the site into the enabled folder, test the config, and reload Nginx:
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
Then give the web server ownership of the files so WordPress can upload media and update itself:
sudo chown -R www-data:www-data /var/www/wordpress
If nginx -t reports an error, read the message and fix that line before reloading. A bad config stops Nginx from serving every site on the server, not just this one.
How do you add HTTPS with Let's Encrypt?
Run Certbot with its Nginx plugin and it issues a free certificate and sets up renewal.
WordPress.org's Requirements page lists HTTPS support as a requirement, and browsers warn visitors away from plain HTTP sites. Let's Encrypt issues free certificates, and Certbot installs them for you.
Install Certbot and its Nginx plugin:
sudo apt install certbot python3-certbot-nginx
Then ask for a certificate for your domain and its www version:
sudo certbot --nginx -d example.com -d www.example.com
Certbot checks that you control the domain, writes the certificate settings into your Nginx server block, and offers to redirect HTTP to HTTPS. Say yes to the redirect so every visitor gets the secure version.
Let's Encrypt certificates last 90 days, according to DigitalOcean's guide to securing Nginx with Let's Encrypt. Certbot adds a systemd timer that runs twice a day and renews any certificate within 30 days of expiry, so renewal is automatic once it is set up.
Test the renewal path right away with sudo certbot renew --dry-run. If the dry run passes, your certificate will renew on its own. If you need the manual steps, see how to install an SSL certificate on WordPress.
How do you check that WordPress works?
Open the site, log in to wp-admin, and read the Site Health screen for warnings.
Visit your domain in a browser first. You should see the WordPress default theme, and the address bar should show the padlock for HTTPS. Then open example.com/wp-admin and log in with the admin account from the install step.
Run these five checks:
- Open Tools, then Site Health, and read the status. Fix anything marked critical.
- Open Site Health, then Info, then Server, and confirm the PHP version is 8.3 or newer.
- Open Settings, then Permalinks, and set the structure to Post name.
- Publish a test post with an image to confirm uploads work.
- Visit the post on the live site to confirm permalinks load without errors.
If a page shows a blank screen or a 500 error, check the Nginx error log at /var/log/nginx/error.log first. Most first-install failures are a wrong database password, a missing PHP extension, or a file ownership problem, and the log names the cause.
Once the live site works, set up a staging copy before you change themes or plugins. The guide to how to set up a staging site for WordPress shows the steps.
What mistakes should you avoid?
The common failures are skipping the firewall, picking too little RAM, and never checking backups.
Avoid these five mistakes:
- Running everything as root instead of a sudo user.
- Picking the cheapest 512 MiB plan for a live site and wondering why pages crawl.
- Skipping the firewall, or opening ports you do not need.
- Using a weak database password, or reusing the same password for the admin account.
- Never testing a backup and a restore, so the first restore attempt happens during a real outage.
Plan about one to two hours for a first install, and about 30 minutes once you know the steps. Keep the server updated with sudo apt update && sudo apt upgrade on a regular schedule, and update WordPress core, themes and plugins from the dashboard as updates appear.
Frequently asked questions
How much does it cost to run WordPress on a VPS?
A small site runs on a $6 to $12 a month VPS, based on DigitalOcean's Basic Droplet prices as of November 2026. Add a domain name, which usually costs about $10 to $15 a year, and the software itself is free. Budget more RAM as traffic grows, since upgrading the server size is cheaper than fixing an overloaded one.
Do I need to know Linux commands to run WordPress on a VPS?
You need basic commands for SSH, file editing and service restarts, but the steps in this guide cover the full install. If the command line feels like too much, a managed WordPress host handles the server for you. A VPS suits people who want full control and are willing to learn the basics.
Should I use Apache or Nginx for WordPress on a VPS?
Both work well, and WordPress.org recommends either Apache or Nginx. This guide uses Nginx because it handles many simultaneous connections with little memory, which suits small VPS plans. Pick the one your tutorials and your own experience cover best, since a familiar stack is easier to fix when something breaks.
How long does a VPS WordPress install take?
A first install takes about one to two hours, including the server setup, the LEMP stack, WordPress and HTTPS. Most of that time goes to reading and checking each step. Once you know the commands, the same install takes about 30 minutes, so keep notes of the exact commands for the next server.
Can I move an existing WordPress site to a VPS later?
Back up the files and database on the old host, copy them to the VPS, import the database, and update wp-config.php with the new database details. Test the copy on the new server before you point the domain at it. A migration plugin can do the same job with fewer manual steps.
Sources
- Requirements WordPress.org
- How to Install WordPress with LEMP on Ubuntu 22.04 DigitalOcean
- Quick Start WP-CLI
- How To Secure Nginx with Let's Encrypt on Ubuntu 22.04 DigitalOcean
- Droplet Pricing DigitalOcean
- Ubuntu Release Cycle Ubuntu
Is your product missing, or something out of date?
Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.
Thanks — we review requests within 3 business days.
Related guides
About the editors
Researched from the primary sources listed above and checked against our editorial rules before publishing.


