Want to run your own WordPress website on a VPS? It’s not as hard as it sounds. You don’t need to be an expert. You just need to follow the steps, one by one.
I’ve done this several times, and I’ll walk you through the process. I’ll also share some tips that helped me avoid problems.
If you like having control and want to save money on hosting, setting up WordPress on a VPS might be a good choice.
What Is a VPS?
A VPS is short for Virtual Private Server. Think of it like renting your own small computer that runs on the internet. You can install what you want and set it up the way you like.
It’s different from shared hosting. With shared hosting, your site is on the same machine as hundreds of others. On a VPS, you get more privacy and control.
Have you used a VPS before?
If not, that’s okay. I’ll keep things simple.
What You Need First
Before we start, make sure you have:
- A VPS running Linux (Debian or Ubuntu is good)
- Root or sudo access (so you can install stuff)
- A domain name (like mywebsite.com)
- A little patience
You don’t need a control panel like cPanel. We’ll install everything by hand.
Step 1: Connect to Your VPS
Once your VPS is ready, connect to it using SSH.
On your computer, open the terminal and type:
ssh root@your-vps-ip
Replace your-vps-ip
with the IP address your hosting company gave you.
Now you’re inside your server.
Step 2: Update the System
It’s always a good idea to update everything first.
If you’re using Debian or Ubuntu, type:
sudo apt update && sudo apt upgrade -y
This keeps your system safe and ready for new software.
Step 3: Install the LAMP Stack
WordPress needs a web server, a database, and PHP to run.
You’ll need to install these three parts:
sudo apt install apache2 mariadb-server php libapache2-mod-php php-mysql -y
This gives you:
- Apache to serve web pages
- MariaDB to store data
- PHP to run WordPress code
Once they’re installed, check Apache is working:
sudo systemctl status apache2
You can also open your server’s IP in a browser. You should see the Apache welcome page.
Step 4: Secure MariaDB
Now we’ll lock down the database:
sudo mysql_secure_installation
You’ll be asked a few questions. I usually answer like this:
- Set root password → Yes
- Remove anonymous users → Yes
- Disallow remote root login → Yes
- Remove test database → Yes
- Reload privilege tables → Yes
This helps protect your data from attacks.
Step 5: Create a Database for WordPress
Let’s create a place for WordPress to store its data.
Enter the MariaDB shell:
sudo mysql
Then type these commands:
CREATE DATABASE wordpress;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'yourpassword';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Remember to choose a strong password for 'yourpassword'
. Write it down somewhere safe.
Step 6: Download and Set Up WordPress
Now we’ll get the latest version of WordPress:
cd /tmp
wget https://wordpress.org/latest.tar.gz
tar -xvzf latest.tar.gz
Move it to the web folder:
sudo mv wordpress /var/www/html/wordpress
Set the right permissions:
sudo chown -R www-data:www-data /var/www/html/wordpress
sudo chmod -R 755 /var/www/html/wordpress
Now let’s configure Apache.
Step 7: Create a Virtual Host
We’ll tell Apache how to serve your new WordPress site.
Create a config file:
sudo nano /etc/apache2/sites-available/wordpress.conf
Paste this in:
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName yourdomain.com
DocumentRoot /var/www/html/wordpress
<Directory /var/www/html/wordpress>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Save the file and exit.
Enable it:
sudo a2ensite wordpress.conf
sudo a2enmod rewrite
sudo systemctl restart apache2
Don’t forget to point your domain’s DNS to your VPS IP.
Step 8: Run the WordPress Installer
Now open your browser and go to your domain.
You’ll see the WordPress setup screen. Choose your language, then fill in:
- Database name:
wordpress
- Username:
wpuser
- Password: the one you created earlier
- Host:
localhost
Click continue and follow the rest of the setup. You’ll create an admin account and site name.
Once done, your WordPress site is live.
Benefits of Using a VPS
I like running WordPress on a VPS for a few reasons:
- You get full control of your server
- You can run many sites on one machine
- It’s often cheaper than managed hosting in the long run
- You can learn how servers work, which helps in the future
It’s not for everyone, but if you like learning and tinkering, it’s worth it.
Two Helpful Lists
Things to Install:
- Apache (web server)
- MariaDB (database)
- PHP and common modules
- WordPress files
- A domain name (linked to your VPS)
Things to Remember:
- Update your system regularly
- Secure MariaDB with
mysql_secure_installation
- Use strong passwords
- Set file permissions for security
- Back up your server often
Common Problems I Faced
At first, I made a few mistakes:
- I forgot to open ports on my VPS firewall. If you use UFW, run
sudo ufw allow 80,443/tcp
. - I mistyped my database password and got the “Error establishing a database connection” message.
- I left the Apache default site active, which caused conflicts. Always disable it with
sudo a2dissite 000-default.conf
.
Don’t be afraid to look up error messages. They usually tell you what’s wrong.
What’s Next?
Once WordPress is installed, you can:
- Pick a theme and make your site look nice
- Add plugins for SEO, backups, or contact forms
- Write your first blog post or create pages
- Secure your site with free SSL (Let’s Encrypt)
Would you like me to write a guide for any of those next?
Final Thoughts
Setting up WordPress on a VPS takes some time, but it gives you more freedom. You’ll learn a lot and have full control over your site.
You’ve now got:
- A working VPS
- Apache, PHP, and MariaDB
- A fresh WordPress site
Keep your server clean, secure, and backed up. Then just focus on building something cool.
What will your website be about?
Let me know if you’d like help with themes, plugins, or backups.