Tutorials

Installing WordPress on VPS with Nginx and SSL

Administrator
By Administrator
Published Sep 30, 2025
6 min read
Installing WordPress on VPS with Nginx and SSL

So You Want to Host WordPress Yourself?

There's something incredibly satisfying about running your own WordPress site on a VPS you control. No shared hosting limitations, no surprise fees, and you actually understand how everything works under the hood.

But let's be honest - setting it up yourself can feel pretty intimidating the first time. I remember staring at a blank terminal window wondering if I was in over my head. Turns out, it's not as complicated as it looks, and today I'm going to walk you through the entire process.

We're going to set up WordPress the right way: on a VPS with Nginx (my preferred web server), PHP, a proper database, and free SSL certificates. By the end of this guide, you'll have a blazing fast WordPress site that you completely control.

Ready? Let's dive in.

Before We Start: What You'll Need

Let's get our checklist sorted first. You'll need:

  • A VPS running Ubuntu (20.04 or 22.04 are great choices)
  • A domain name pointed to your VPS IP address
  • SSH access with sudo privileges
  • About an hour of focused time
  • Patience - there will be a few moments where things might not work immediately

Got all that? Great. Let's start building something awesome.

Step 1: Get Your Server Ready

First things first, let's make sure our server is up to date and has everything we need:

sudo apt update && sudo apt upgrade -y

Now let's install the essentials - Nginx, PHP, and MySQL (the classic LEMP stack):

sudo apt install nginx mysql-server php-fpm php-mysql -y

While that's installing, let's talk about what we just installed:

  • Nginx: Your web server - super fast and efficient
  • MySQL: Your database - where all your WordPress content will live
  • PHP-FPM: The PHP processor - WordPress is built on PHP

Step 2: Secure Your MySQL Setup

MySQL comes with a handy security script. Run it:

sudo mysql_secure_installation

This will ask you a few questions. Here's what I recommend:

  • Set up the Validate Password component? Press 'Y'
  • Choose password strength level - I usually go with 2 (medium)
  • Set a strong root password - don't skip this!
  • Remove anonymous users? Press 'Y'
  • Disallow root login remotely? Press 'Y'
  • Remove test database? Press 'Y'
  • Reload privilege tables? Press 'Y'

Step 3: Create Your WordPress Database

Now we need to create a database specifically for WordPress. Log into MySQL:

sudo mysql -u root -p

Enter the password you just created, then run these commands:

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

Pro tip: Use a really strong password here. Write it down somewhere secure - you'll need it in a few minutes.

Step 4: Configure PHP for WordPress

WordPress has some specific PHP requirements. Let's install the necessary extensions:

sudo apt install php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip -y

Now let's tweak a few PHP settings for better WordPress performance:

sudo nano /etc/php/8.1/fpm/php.ini

(Note: your PHP version might be different - check with php -v)

Find and update these values:

memory_limit = 256M
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300

Restart PHP-FPM to apply the changes:

sudo systemctl restart php8.1-fpm

Step 5: Download and Set Up WordPress

Time to get WordPress itself! Let's download it to the right place:

cd /tmp
wget https://wordpress.org/latest.tar.gz
tar -xzvf latest.tar.gz

Now copy it to your web directory and set permissions:

sudo cp -a /tmp/wordpress/* /var/www/yourdomain.com/
sudo chown -R www-data:www-data /var/www/yourdomain.com/
sudo find /var/www/yourdomain.com/ -type d -exec chmod 755 {} \;
sudo find /var/www/yourdomain.com/ -type f -exec chmod 644 {} \;

Replace yourdomain.com with your actual domain name.

Step 6: Configure Nginx for WordPress

This is where the magic happens. We need to tell Nginx how to handle WordPress. Create a new config file:

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

And paste this configuration:

server {
    listen 80;
    server_name yourdomain.com www.yourdomain.com;
    root /var/www/yourdomain.com;
    index index.php index.html index.htm;

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

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

    location ~ /\.ht {
        deny all;
    }

    # WordPress security hardening
    location = /wp-config.php {
        deny all;
    }

    location = /wp-admin/install.php {
        allow all;
    }
}

Enable your site and restart Nginx:

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

Step 7: Add Free SSL with Let's Encrypt

No modern website is complete without HTTPS. Let's get you a free SSL certificate:

sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com

Follow the prompts. When it asks about HTTP to HTTPS redirection, choose option 2 to redirect all traffic.

Step 8: Run the WordPress Installation

Now for the exciting part! Open your browser and go to https://yourdomain.com.

You should see the famous WordPress setup screen. Here's what you'll need:

  • Database Name: wordpress
  • Username: wpuser
  • Password: That strong password you created earlier
  • Database Host: localhost
  • Table Prefix: wp_ (default is fine)

Click "Run the installation" and you're golden!

Troubleshooting: When Things Don't Work

Don't worry if you hit a snag - it happens to everyone. Here are the most common issues:

404 Errors on Pages

If your pretty permalinks aren't working, make sure your Nginx config has the try_files $uri $uri/ /index.php?$args; line and restart Nginx.

Upload Issues

Can't upload media? Check your PHP upload limits and make sure the uploads directory has the right permissions:

sudo chown -R www-data:www-data /var/www/yourdomain.com/wp-content/uploads

Database Connection Errors

Double-check your database credentials in wp-config.php. Also make sure MySQL is actually running: sudo systemctl status mysql

White Screen of Death

Usually a PHP memory or syntax error. Check your PHP error logs: sudo tail -f /var/log/php8.1-fpm.log

Pro Tips for Better Performance

Install a Caching Plugin

Once WordPress is running, install a caching plugin like WP Rocket or W3 Total Cache. Your visitors will thank you.

Use a CDN

Cloudflare has a great free tier that can dramatically speed up your site.

Regular Backups

Set up automated backups. I use UpdraftPlus - it's free and works great.

What's Next?

Congratulations! You now have a fully functional WordPress site running on your own VPS with SSL. Pretty awesome, right?

From here, you can:

  • Install your favorite theme and plugins
  • Set up regular backups
  • Configure monitoring to keep an eye on performance
  • Maybe even add multiple sites to the same server

The beauty of hosting your own WordPress site is that you're in complete control. No more shared hosting limitations, no more surprise bills, and you actually understand how everything works together.

Running your own server does require some maintenance, but the freedom and performance gains are absolutely worth it. Plus, you learn a ton along the way.

Have questions or run into any issues? Drop them in the comments below - I've been through this process dozens of times and have probably encountered whatever you're dealing with.

Happy WordPressing! 🚀

Related Articles

How to Backup and Restore a Website on VPS Linux

How to Backup and Restore a Website on VPS Linux

Oct 03, 2025

How to Backup and Restore a Website on VPS Linux That moment when you realize your website is gon...

Setting Up Load Balancing with Nginx for High Traffic Sites

Setting Up Load Balancing with Nginx for High Traffic Sites

Oct 03, 2025

Setting Up Load Balancing with Nginx for High Traffic Sites Your website is growing. Traffic is i...

How to Monitor Server Resources with htop and netstat

How to Monitor Server Resources with htop and netstat

Oct 03, 2025

How to Monitor Server Resources with htop and netstat Ever wonder why your website suddenly slows...

Basic Firewall Configuration for Linux Web Servers

Basic Firewall Configuration for Linux Web Servers

Oct 03, 2025

Basic Firewall Configuration for Linux Web Servers Your web server is like a house in a busy neig...