Tutorial 📅 February 17, 2026 📖 18 min read

How to Install WordPress on a VPS in 2026: Complete Step-by-Step Guide

Install WordPress on your own VPS with a full LEMP stack (Linux, Nginx, MySQL, PHP). This guide covers everything from server setup to performance optimization and SSL certificates.

WordPress powers over 43% of all websites on the internet. While managed WordPress hosting is convenient, installing WordPress on your own VPS gives you complete control, better performance, and significant cost savings at scale. This guide walks you through every step of the process.

Why Install WordPress on a VPS?

Before diving into the installation, let's understand why a VPS is the best choice for serious WordPress sites.

FeatureShared HostingVPS HostingManaged WordPress
Price$3-10/month$5-20/month$25-100/month
PerformanceSlow (shared resources)Fast (dedicated resources)Fast (optimized)
ControlLimitedFull root accessLimited
ScalabilityLimitedEasy vertical scalingProvider-dependent
Custom SoftwareNoYes - anythingWordPress only
SSLSometimes includedFree (Let's Encrypt)Included
Multiple SitesLimitedUnlimitedUsually per-site pricing
Best of Both Worlds: With VPS Commander, you get the control of a VPS with the simplicity of managed hosting. Install WordPress, manage files, and monitor your server through a visual web interface - no terminal commands needed.

Step 1: Initial VPS Setup

You need a VPS running Ubuntu 22.04 LTS or 24.04 LTS. If you don't have one yet, check our VPS provider comparison to find the best option for your budget.

Minimum Requirements for WordPress

Connect to your server and perform initial setup:

# Connect via SSH
ssh root@your_server_ip

# Update the system
apt update && apt upgrade -y

# Create a non-root user
adduser wordpress
usermod -aG sudo wordpress

# Set up basic firewall
ufw allow OpenSSH
ufw allow 'Nginx Full'
ufw enable

Step 2: Install Nginx

Nginx is faster and more efficient than Apache for serving WordPress sites, especially under high traffic.

# Install Nginx
sudo apt install nginx -y

# Start and enable Nginx
sudo systemctl start nginx
sudo systemctl enable nginx

# Verify installation
sudo systemctl status nginx

Visit http://your_server_ip in your browser - you should see the Nginx welcome page.

Step 3: Install MySQL and Create Database

# Install MySQL
sudo apt install mysql-server -y

# Secure the installation
sudo mysql_secure_installation
# Answer: Yes to all security questions

# Log into MySQL
sudo mysql

# Create WordPress database and user
CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'YourStrongPassword123!';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Security Warning: Replace YourStrongPassword123! with a strong, unique password. Never use the same password for your database as your server login. Use a password generator for maximum security.

Step 4: Install PHP and Required Extensions

WordPress requires PHP and several extensions for full functionality.

# Install PHP 8.3 and required extensions
sudo apt install php8.3-fpm php8.3-mysql php8.3-curl php8.3-gd \
  php8.3-intl php8.3-mbstring php8.3-soap php8.3-xml \
  php8.3-xmlrpc php8.3-zip php8.3-imagick php8.3-opcache -y

# Verify PHP version
php --version

# Check PHP-FPM is running
sudo systemctl status php8.3-fpm

Optimize PHP Configuration

# Edit PHP configuration
sudo nano /etc/php/8.3/fpm/php.ini

# Find and update these values:
upload_max_filesize = 64M
post_max_size = 64M
memory_limit = 256M
max_execution_time = 300
max_input_time = 300

# Restart PHP-FPM
sudo systemctl restart php8.3-fpm
✨Trusted by 1000+ developers worldwide

Install WordPress without touching the terminal

VPS Commander's automated workflows can set up your entire LEMP stack and WordPress installation with just a few clicks. No SSH knowledge required.

Get started for free Sign in
400+
Automated workflows
1000+
Active users
99.9%
Uptime guarantee

Step 5: Download and Configure WordPress

# Download WordPress
cd /tmp
curl -O https://wordpress.org/latest.tar.gz

# Extract and move to web root
tar xzvf latest.tar.gz
sudo cp -a /tmp/wordpress/. /var/www/yourdomain.com/html/

# Set proper ownership
sudo chown -R www-data:www-data /var/www/yourdomain.com/html/

# Set proper permissions
sudo find /var/www/yourdomain.com/html/ -type d -exec chmod 750 {} \;
sudo find /var/www/yourdomain.com/html/ -type f -exec chmod 640 {} \;

Configure wp-config.php

# Create wp-config.php from sample
cd /var/www/yourdomain.com/html/
sudo cp wp-config-sample.php wp-config.php

# Generate security keys
curl -s https://api.wordpress.org/secret-key/1.1/salt/

# Edit wp-config.php
sudo nano wp-config.php

# Update these lines with your database info:
# define('DB_NAME', 'wordpress');
# define('DB_USER', 'wpuser');
# define('DB_PASSWORD', 'YourStrongPassword123!');
# define('DB_HOST', 'localhost');

# Replace the placeholder keys with the generated ones above

Step 6: Configure Nginx for WordPress

# Create Nginx server block
sudo nano /etc/nginx/sites-available/yourdomain.com

Add this optimized WordPress configuration:

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

    # Max upload size
    client_max_body_size 64M;

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

    # PHP handling
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php8.3-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    # Security: deny access to sensitive files
    location ~ /\.ht {
        deny all;
    }

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

    location ~* /wp-includes/.*.php$ {
        deny all;
    }

    # Cache static assets
    location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff2|woff|ttf|eot)$ {
        expires 30d;
        add_header Cache-Control "public, immutable";
        access_log off;
    }

    # Gzip compression
    gzip on;
    gzip_types text/plain text/css application/json application/javascript text/xml application/xml text/javascript image/svg+xml;
    gzip_min_length 256;
    gzip_vary on;

    # Security headers
    add_header X-Frame-Options "SAMEORIGIN" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header X-XSS-Protection "1; mode=block" always;
}
# Enable the site
sudo ln -s /etc/nginx/sites-available/yourdomain.com /etc/nginx/sites-enabled/

# Remove default site
sudo rm /etc/nginx/sites-enabled/default

# Test configuration
sudo nginx -t

# Reload Nginx
sudo systemctl reload nginx

Step 7: SSL with Let's Encrypt

# Install Certbot
sudo apt install certbot python3-certbot-nginx -y

# Get SSL certificate
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com

# Verify auto-renewal
sudo certbot renew --dry-run
WordPress is Ready! Visit https://yourdomain.com to complete the WordPress installation wizard. Choose your language, enter your site title, create an admin account, and you're live!

Step 8: WordPress Performance Optimization

Enable OPcache

# Edit OPcache configuration
sudo nano /etc/php/8.3/fpm/conf.d/10-opcache.ini

# Add these settings:
opcache.enable=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.revalidate_freq=2

# Restart PHP-FPM
sudo systemctl restart php8.3-fpm

Install Redis for Object Caching

# Install Redis
sudo apt install redis-server php8.3-redis -y

# Enable Redis
sudo systemctl enable redis-server
sudo systemctl start redis-server

# Restart PHP-FPM
sudo systemctl restart php8.3-fpm

# In WordPress, install the "Redis Object Cache" plugin
# and enable it from Settings > Redis

Recommended WordPress Plugins for Performance

WordPress VPS Hosting Cost Comparison

ProviderPlanPrice/MonthWordPress Sites
HetznerCX21 (4GB RAM)$5.835-10 sites
DigitalOceanBasic (2GB RAM)$123-5 sites
VultrRegular (2GB RAM)$123-5 sites
LinodeShared (2GB RAM)$123-5 sites
Kinsta (Managed)Starter$351 site
WP Engine (Managed)Startup$301 site

As you can see, hosting WordPress on a VPS is significantly cheaper than managed hosting, especially when hosting multiple sites.

✨Trusted by 1000+ developers worldwide

Manage your WordPress VPS effortlessly

Update plugins, manage files, view logs, and monitor server resources - all from a single web dashboard. No SSH required.

Get started for free Sign in
400+
Automated workflows
1000+
Active users
99.9%
Uptime guarantee

Troubleshooting Common WordPress Issues

White Screen of Death

Cause: PHP memory limit exceeded or plugin conflict.

# Increase PHP memory limit
sudo nano /etc/php/8.3/fpm/php.ini
# Set: memory_limit = 512M

# Disable all plugins via command line
cd /var/www/yourdomain.com/html/wp-content/
sudo mv plugins plugins.bak
sudo mkdir plugins
# Visit wp-admin to troubleshoot, then restore one by one

Database Connection Error

# Test MySQL connection
mysql -u wpuser -p wordpress

# Check MySQL is running
sudo systemctl status mysql

# Verify wp-config.php credentials match
cat /var/www/yourdomain.com/html/wp-config.php | grep DB_

Permission Errors

# Reset WordPress file permissions
sudo chown -R www-data:www-data /var/www/yourdomain.com/html/
sudo find /var/www/yourdomain.com/html/ -type d -exec chmod 750 {} \;
sudo find /var/www/yourdomain.com/html/ -type f -exec chmod 640 {} \;

# Make wp-content writable for uploads
sudo chmod -R 770 /var/www/yourdomain.com/html/wp-content/

Frequently Asked Questions

How much RAM do I need for WordPress on a VPS?

For a single WordPress site with moderate traffic (up to 50,000 visits/month), 1 GB RAM is sufficient. For multiple sites or WooCommerce, we recommend 2-4 GB RAM. High-traffic sites may need 4-8 GB.

Is Nginx better than Apache for WordPress?

Yes, in most cases. Nginx uses less memory, handles more concurrent connections, and serves static files faster. It's particularly better for high-traffic WordPress sites. The only downside is no .htaccess support.

Can I host multiple WordPress sites on one VPS?

Absolutely. Create separate Nginx server blocks, databases, and directories for each site. A 2 GB RAM VPS can easily host 3-5 WordPress sites with moderate traffic.

How do I update WordPress on a VPS?

You can update through the WordPress admin dashboard as usual. For security, make a backup first using tar -czf backup.tar.gz /var/www/yourdomain.com/ and mysqldump.

Should I use MySQL or MariaDB?

Both work perfectly with WordPress. MariaDB is a drop-in MySQL replacement that some consider faster. For most WordPress sites, the performance difference is negligible.

How do I secure my WordPress VPS?

Follow our complete VPS security guide. Key steps: disable root SSH, use key-based authentication, install fail2ban, keep software updated, and use strong passwords.

Conclusion

Installing WordPress on a VPS gives you the best combination of performance, control, and value. With the LEMP stack (Linux, Nginx, MySQL, PHP), your WordPress site will be faster and more reliable than on shared hosting.

The key steps are: set up your VPS, install the LEMP stack, download WordPress, configure Nginx, and add SSL. With proper caching and optimization, a $6/month VPS can handle tens of thousands of monthly visitors.

For hassle-free server management, VPS Commander provides visual tools to manage your WordPress VPS without terminal commands.

Next Steps: Learn how to secure your WordPress VPS, explore essential Linux commands, or check our best VPS providers comparison for the perfect hosting.

Related Articles