WordPress

How to Install WordPress on a VPS (Step-by-Step)

Administrator
By Administrator
Published Oct 06, 2025
5 min read

How to Install WordPress on a VPS (Step-by-Step)

Installing WordPress on a VPS gives you complete control over your website's performance, security, and functionality. This comprehensive step-by-step guide will walk you through the entire process, from server setup to launching your WordPress site.

Prerequisites

Before we begin, ensure you have:

  • A VPS running Ubuntu 20.04 or 22.04
  • A domain name pointed to your VPS IP address
  • li>SSH access with sudo privileges
  • Basic knowledge of command line operations

The installation process takes approximately 30-45 minutes to complete.

Step 1: Update Your System

Start by updating your package lists and upgrading installed packages:

sudo apt update && sudo apt upgrade -y

**Screenshot description**: Terminal showing package update progress with green checkmarks indicating successful updates.

Step 2: Install the LEMP Stack

WordPress requires Nginx, PHP, and MySQL (LEMP stack). Install these components:

sudo apt install nginx mysql-server php-fpm php-mysql php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip -y

This command installs:

  • Nginx (web server)
  • MySQL (database server)
  • li>PHP-FPM (PHP processor) li>Essential PHP extensions for WordPress

**Screenshot description**: Terminal showing installation progress with package names being downloaded and configured.

Step 3: Secure MySQL Installation

Run the MySQL security script to secure your database:

sudo mysql_secure_installation

Follow these recommendations during setup:

  • Set up Validate Password Component: Yes
  • li>Password strength level: 2 (Medium) li>Set a strong root password li>Remove anonymous users: Yes li>Disallow root login remotely: Yes li>Remove test databases: Yes li>Reload privilege tables: Yes

**Screenshot description**: Interactive prompt showing MySQL security configuration options.

Step 4: Create WordPress Database

Log into MySQL and create a dedicated database for WordPress:

sudo mysql -u root -p

Enter your MySQL root password, then run these commands:

CREATE DATABASE wordpress_db;
CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'YourStrongPassword123!';
GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wordpress_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

**Screenshot description**: MySQL command line interface showing database and user creation commands.

Step 5: Configure PHP

Adjust PHP settings for better WordPress performance:

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

Find and modify these settings:

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

Restart PHP-FPM to apply changes:

sudo systemctl restart php8.1-fpm

**Screenshot description**: Text editor showing php.ini file with WordPress-recommended settings highlighted.

Step 6: Download WordPress

Download the latest WordPress to your server:

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

Create the web directory and copy WordPress files:

sudo mkdir -p /var/www/yourdomain.com
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 {} \;

**Screenshot description**: File browser showing WordPress directory structure with proper permissions.

Step 7: Configure Nginx

Create a Nginx configuration file for your site:

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

Add 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;
    }

    location = /wp-config.php {
        deny all;
    }
}

Enable the site and restart Nginx:

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

**Screenshot description**: Nginx configuration file with WordPress-specific rules and terminal testing configuration syntax.

Step 8: Install Let's Encrypt SSL

Install Certbot and obtain free SSL certificate:

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

Choose option 2 to redirect HTTP traffic to HTTPS when prompted.

**Screenshot description**: Certbot interactive prompt showing SSL certificate configuration options.

Step 9: Complete WordPress Installation

Open your browser and navigate to https://yourdomain.com. You'll see the WordPress setup screen. Fill in these details:

  • Database Name: wordpress_db
  • Username: wordpress_user
  • Password: YourStrongPassword123!
  • Database Host: localhost
  • Table Prefix: wp_ (default is fine)

Click "Run the installation" and follow the remaining steps to create your admin account.

**Screenshot description**: WordPress web installation interface with form fields highlighted.

Step 10: Post-Installation Configuration

Set Permalinks

In WordPress admin, go to Settings → Permalinks and choose "Post name" for better SEO:

Settings → Permalinks → Post name → Save Changes

Install Essential Plugins

Install these must-have plugins:

  • Yoast SEO (for search engine optimization)
  • li>Wordfence (for security) li>WPForms (for contact forms) li>W3 Total Cache (for performance)

**Screenshot description**: WordPress admin plugin installation screen with popular plugins highlighted.

Troubleshooting Common Issues

404 Errors

If you get 404 errors, ensure your Nginx config includes:

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

Permission Issues

Fix file permissions:

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 {} \;

Database Connection Errors

Check wp-config.php database credentials and ensure MySQL is running:

sudo systemctl status mysql

**Screenshot description**: Error log showing database connection issues and corresponding fixes.

Conclusion

Congratulations! You've successfully installed WordPress on your VPS. Your site is now running with:

    li>Nginx web server for optimal performance li>PHP-FPM for fast PHP processing li>MySQL database for content storage li>Free SSL certificate for security

Next steps: Install your theme, configure plugins, and start creating content. Regularly update WordPress, themes, and plugins to maintain security and performance.

**Screenshot description**: Final WordPress admin dashboard with success message.

Your WordPress VPS installation is complete! 🚀

Related Articles

10 Must-Have WordPress Plugins for Every Website

10 Must-Have WordPress Plugins for Every Website

Oct 06, 2025

10 Must-Have WordPress Plugins for Every Website WordPress plugins are what make WordPress so pow...

Using the WordPress Customizer: A Beginner's Walkthrough

Using the WordPress Customizer: A Beginner's Walkthrough

Oct 06, 2025

Using the WordPress Customizer: A Beginner's Walkthrough The WordPress Customizer is one of the m...

How to Customize Your WordPress Theme Without Coding

How to Customize Your WordPress Theme Without Coding

Oct 06, 2025

How to Customize Your WordPress Theme Without Coding Want to make your WordPress site stand out b...

How to Choose the Perfect WordPress Theme for Your Website

Oct 06, 2025

How to Choose the Perfect WordPress Theme for Your Website Choosing the right WordPress theme is on...