How to Host a Production ready WordPress Website on VPS (Step-by-Step with Nginx, PHP, and Cloudflare SSL)
techques
Hosting Wordpress using Ubuntu VPS server
Launching a WordPress website on your own VPS gives you complete control, faster performance, and better security — all at a fraction of the cost of shared hosting. In this guide, you’ll learn how to install and configure WordPress on a VPS using Nginx, PHP-FPM, MySQL, and Cloudflare SSL (Full Strict mode).
Table of Contents
Why Host WordPress on a VPS?
A VPS (Virtual Private Server) gives you:
Ability to use Nginx + Cloudflare for blazing-fast performance
Root access and full control over your environment
Scalability as your traffic grows
Ability to use Nginx + Cloudflare for blazing-fast performance
Fig: Running htop command to see consumption of RAM on Ubuntu VPS Server
Step 1: Prepare Your VPS
We’ll assume you’re using Ubuntu 22.04+ on a VPS from providers like AWS, DigitalOcean, Linode, or others.
sudo systemctl enable --now nginx mysql php8.3-fpm
Step 2: Set Up the WordPress Database
Log in to MySQL:
sudo mysql -u root
Create a database and user:
CREATE DATABASE wordpress;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'StrongPassword';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Step 3: Download and Configure WordPress
Rather than using the old Ubuntu APT package, which often lags behind and causes compatibility issues, we’ll install WordPress directly from WordPress.org — the official and most reliable source. This method ensures you’re always on the latest stable release, compatible with modern PHP versions and supported by the global WordPress community.
Process 1: Create the Web Directory
We’ll create a dedicated directory for hosting WordPress files. This guide uses/srv/www, which is a secure and clean location for web applications:
Click Create Certificate → Select Let Cloudflare generate the key and certificate → Choose your domain (e.g., example.com, www.example.com) → Download both .pem and .key files.
Upload them to your server:
sudo mkdir -p /srv/www/ssl
cd ssl
sudo nano cloudflare.key
Ensure your Cloudflare DNS A record is Proxied (orange cloud). If it’s “DNS only (grey cloud),” the browser will show invalid SSL certificate — because Cloudflare’s origin cert is trusted only between Cloudflare ↔ your VPS.
You’ve just learned how to host a WordPress site on your own VPS using Nginx, PHP, and Cloudflare SSL — the same setup used by top-performing websites.
This method gives you:
Full control
Maximum speed
Strong Cloudflare security
Reliable HTTPS with Full Strict validation
Now your WordPress site is production-ready, scalable, and fully secure. 🚀
Pro Tip: Updating Your WordPress Site URL When Moving to Production
If you’ve been developing your site under a demo domain like 👉 https://demo.onlineread.com and now want to move it to your live production domain 👉 https://onlineread.com
you’ll need to update the WordPress URL settings inside your database — not just in Nginx or Cloudflare. Otherwise, your WordPress dashboard and pages may still redirect or load from the old demo domain.
Login to your mysql:
sudo mysql -u root -p
Then run (you have to find your database name and enter inside the table and then perform below command)
mysql> SELECT option_name, option_value FROM wp_options WHERE option_name = 'siteurl' OR option_name = 'home';
Output:
+-------------+-----------------------------+
| option_name | option_value |
+-------------+-----------------------------+
| home | https://demo.onlineread.com |
| siteurl | https://demo.onlineread.com |
+-------------+-----------------------------+
2 rows in set (0.00 sec)
Now, although you change your url to production in cloudflare and nginx, you still have to change it here manually
mysql> UPDATE wp_options SET option_value = 'https://onlineread.com' WHERE option_name = 'siteurl' OR option_name = 'home';
Output:
Query OK, 2 rows affected (0.00 sec)
Rows matched: 2 Changed: 2 Warnings: 0
Now, you have changed your domain from demo.onlineread.com (development) to onlineread.com (production). Note that you have to change the domain url in cloudflare DNS and in Nginx too.
Frequently Asked Questions
1. Do I need SSL on my VPS if I’m using Cloudflare?
Yes. Even if Cloudflare provides SSL, using your own certificate (Full or Full Strict mode) ensures end-to-end encryption between Cloudflare and your VPS.
2. How do I change my WordPress domain from demo to production?
Update your siteurl and home values in the wp_options table of your WordPress database. Also update your Nginx config and Cloudflare DNS.
3. What is the best way to secure a WordPress site on VPS?
Use Nginx with SSL, Cloudflare for CDN and firewall, disable XML-RPC, keep plugins updated, and restrict file permissions.
4. Why does my domain still point to the old site after changes?
This usually happens due to DNS or browser caching. Clear Cloudflare cache, browser cache, and confirm your A-record points to the correct VPS IP. Don’t forget to update at site url and home url in you database too.