How to Install WordPress on Your VPS (Step-by-Step Guide 2025)
WordPress is the most popular content management system (CMS) in the world. Whether you're setting up a personal blog or a business site, installing WordPress on your VPS gives you full control, speed, and flexibility. This guide walks you through the complete process.
Prerequisites
- A VPS with Ubuntu or Debian installed (similar steps apply to other distros)
- Root or sudo access
- A domain name (optional but recommended)
Step 1: Update Your System
sudo apt update && sudo apt upgrade -yStep 2: Install LAMP Stack (Linux, Apache, MySQL, PHP)
Install Apache:
sudo apt install apache2 -yInstall MySQL:
sudo apt install mysql-server -y
sudo mysql_secure_installationCreate a WordPress database:
sudo mysql -u root -p
CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'strongpassword';
GRANT ALL ON wordpress.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;Install PHP:
sudo apt install php libapache2-mod-php php-mysql php-cli php-curl php-xml php-gd php-mbstring php-zip -yRestart Apache:
sudo systemctl restart apache2Step 3: Download WordPress
cd /tmp
curl -O https://wordpress.org/latest.tar.gz
tar -xvzf latest.tar.gz
sudo mv wordpress /var/www/html/Set permissions:
sudo chown -R www-data:www-data /var/www/html/wordpress
sudo chmod -R 755 /var/www/html/wordpressStep 4: Configure Apache for WordPress
Create a new virtual host file:
sudo nano /etc/apache2/sites-available/wordpress.confPaste:
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/wordpress
ServerName example.com
<Directory /var/www/html/wordpress/>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>Enable site and rewrite module:
sudo a2ensite wordpress.conf
sudo a2enmod rewrite
sudo systemctl reload apache2Step 5: Finish Installation in Browser
- Visit
http://your-server-ipor your domain. - Follow the on-screen WordPress setup (choose language, site title, username, etc.)
Optional: Enable HTTPS with Let’s Encrypt
To enable HTTPS using Let’s Encrypt, you must have a registered domain name pointed at your server’s public IP address (via A or AAAA DNS records).
sudo apt install certbot python3-certbot-apache -y
sudo certbot --apacheFollow the prompts to choose your domain and configure HTTPS automatically.
Summary
You've now installed a fully functional WordPress site on your VPS. From here, you can install themes, plugins, and customize to fit your brand.