We earn commissions when you shop through the links below. Learn more
How to Install WordPress on a VPS (Nginx, Ubuntu)
Run WordPress on your own VPS for more speed and control than shared hosting. Choose the one-click route or install the full stack yourself with Nginx, MariaDB, PHP and a free SSL certificate, step by step.
One-click or manualNginx + MariaDB + PHPFree SSLUbuntu LTS
Choose your route
Three ways to get WordPress on a VPS
Step 1
Get a server and point your domain at it
WordPress runs well on 2 GB of RAM; 1 GB works for a small, low-traffic site. Create an Ubuntu 26.04 or 24.04 server with your SSH key, then add an A record for your domain pointing to the server’s IP address at your domain registrar.
New to servers? Follow our guide on how to set up a VPS first, including the user and firewall steps.
Good WordPress VPS picks
- Hostinger: 4 GB RAM for about $5.19/month with our extra 20% off, and a WordPress template.
- DigitalOcean: one-click WordPress Droplet and great docs.
- RackNerd: the cheapest yearly option for a small blog.
Steps 2–4
Install Nginx, MariaDB and PHP
2. Install the stack
sudo apt update
sudo apt install -y nginx mariadb-server php-fpm php-mysql php-curl php-gd php-mbstring php-xml php-zip php-intl php-imagick
sudo ufw allow 'Nginx Full'
3. Create the database
sudo mysql -e "CREATE DATABASE wordpress;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'change-this-password';
GRANT ALL ON wordpress.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;"
4. Download WordPress
cd /var/www
sudo curl -O https://wordpress.org/latest.tar.gz
sudo tar xzf latest.tar.gz && sudo rm latest.tar.gz
sudo chown -R www-data:www-data /var/www/wordpress
Use a long, random database password instead of change-this-password, and keep it somewhere safe; WordPress asks for it during setup.
Step 5
Configure Nginx for WordPress
Find your PHP version’s socket with ls /run/php/ (for example php8.3-fpm.sock). Then create /etc/nginx/sites-available/wordpress with this, replacing the domain and socket name:
server {
listen 80;
server_name example.com www.example.com;
root /var/www/wordpress;
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 ~ /\.ht {
deny all;
}
}
Enable the site
sudo ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/
sudo rm /etc/nginx/sites-enabled/default
sudo nginx -t && sudo systemctl reload nginx
6. Add free SSL from Let’s Encrypt
sudo apt install -y certbot python3-certbot-nginx
sudo certbot --nginx -d example.com -d www.example.com
Step 7
Finish the WordPress installer
Open https://example.com in your browser. Choose your language, enter the database name (wordpress), user (wpuser) and password from step 3, leave the host as localhost, then set your site title and admin account.
Use a unique admin username and a strong password; bots try “admin” first.
After you launch
- Turn on your provider’s backups or snapshots.
- Keep WordPress, plugins and the server updated.
- Add a caching plugin or Redis for speed.
- Lock down SSH and use key-only login.
Our SSH hardening guide covers that last step in 10 minutes.
Need a server?
Pick a VPS for WordPress
WordPress runs best with 2 GB of RAM or more. These hosts give you that for a few dollars a month.
DigitalOcean
Simple cloud servers with great docs. Add your SSH key when you create a Droplet.
From about $4/month
View DigitalOcean dealsHostinger
4 GB of RAM and NVMe storage on the entry VPS plan, with an easy control panel.
About $5.19/month on a 24-month term with our extra 20% off
Get 20% off Hostinger VPSRackNerd
Yearly KVM VPS deals for about the price of one month elsewhere. Great for learning.
From about $11/year on promo
View RackNerd dealsPrices are approximate and change often. Check each provider’s site before you buy.
FAQ
WordPress VPS questions, answered
Is a VPS better than shared hosting for WordPress?
A VPS gives you dedicated resources, more speed and full control, and it often costs about the same as good shared hosting. The trade-off is that you manage updates and security yourself.
How much RAM does WordPress need on a VPS?
1 GB can run a small, low-traffic site. 2 GB is comfortable for most sites, and 4 GB gives room for WooCommerce, several sites or caching tools like Redis.
Nginx or Apache for WordPress?
Both work well. Nginx uses less memory and handles traffic spikes efficiently, which suits small VPS plans. Apache supports .htaccess files, which some plugins expect.
Can I host several WordPress sites on one VPS?
Yes. Create a separate database, folder and Nginx server block for each site, or use a control panel that manages multiple sites for you.
Is the SSL certificate really free?
Yes. Let’s Encrypt certificates are free and Certbot renews them automatically before they expire.
How do I move an existing WordPress site to my VPS?
Use a migration plugin to export the site, set up WordPress on the VPS as above, import the backup, then point your domain at the new server.
Pick a fast VPS for WordPress
Compare the best VPS hosting by RAM, price and features, and find the right home for your site.