How to Host Multiple WordPress and WooCommerce Sites on Contabo VPS with Ubuntu 22.04

Here is your step-by-step guide to deploy multiple WordPress + WooCommerce sites on your Contabo VPS (Ubuntu 22.04, NGINX, PHP 8.2, MariaDB, Redis, SSL):

Step-by-Step Deployment Guide (LEMP Stack)

1. Initial VPS Setup

# Update packages
sudo apt update && sudo apt upgrade -y

# Set correct timezone
sudo timedatectl set-timezone Asia/Kolkata

# Install basic tools
sudo apt install curl wget git unzip htop ufw -y

2. Install NGINX

sudo apt install nginx -y

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

3. Install PHP 8.2 + Extensions

sudo add-apt-repository ppa:ondrej/php -y
sudo apt update

sudo apt install php8.2 php8.2-fpm php8.2-mysql php8.2-curl php8.2-xml php8.2-mbstring php8.2-zip php8.2-gd php8.2-bcmath php8.2-intl php8.2-cli php8.2-soap -y

# Configure PHP-FPM
sudo systemctl enable php8.2-fpm
sudo systemctl start php8.2-fpm

4. Install MariaDB (MySQL Alternative)

sudo apt install mariadb-server -y

sudo systemctl start mariadb
sudo systemctl enable mariadb

# Secure MariaDB
sudo mysql_secure_installation

Example settings:

  • Set root password: Yes

  • Remove anonymous users: Yes

  • Disallow remote root login: Yes

  • Remove test DB: Yes

5. Create Database for Each WordPress Site

# Login to MySQL
sudo mysql -u root -p

# Example for 1st site
CREATE DATABASE wp1_db;
CREATE USER 'wp1_user'@'localhost' IDENTIFIED BY 'StrongPasswordHere';
GRANT ALL PRIVILEGES ON wp1_db.* TO 'wp1_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Repeat for multiple sites (wp2_db, wp3_db, etc.)

6. Install Redis (Object Cache)

sudo apt install redis-server -y
sudo systemctl enable redis
sudo systemctl start redis

Install Redis PHP extension:

sudo apt install php8.2-redis -y
sudo systemctl restart php8.2-fpm

7. Download & Configure WordPress (Multiple Sites)

Example for site1.com:

cd /var/www/
sudo mkdir site1.com && cd site1.com

sudo wget https://wordpress.org/latest.zip
sudo unzip latest.zip
sudo mv wordpress/* .
sudo rm -rf wordpress latest.zip

# Set permissions
sudo chown -R www-data:www-data /var/www/site1.com
sudo chmod -R 755 /var/www/site1.com

Repeat for site2.com, etc.

8. Configure NGINX Virtual Host

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

Paste config:

server {
    listen 80;
    server_name site1.com www.site1.com;

    root /var/www/site1.com;
    index index.php index.html;

    access_log /var/log/nginx/site1.access.log;
    error_log /var/log/nginx/site1.error.log;

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

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

    location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
        expires max;
        log_not_found off;
    }

    location ~ /\.ht {
        deny all;
    }
}

Enable it:

sudo ln -s /etc/nginx/sites-available/site1.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

Repeat for site2.com, etc.

9. Install SSL with Let’s Encrypt

Install Certbot:

sudo apt install certbot python3-certbot-nginx -y

Generate SSL for each domain:

sudo certbot --nginx -d site1.com -d www.site1.com

Repeat for all domains.

Enable auto-renewal:

sudo systemctl enable certbot.timer

10. Final WordPress Setup

Visit:
http://site1.com or https://site1.com
Follow the UI to complete installation. Use the database, user, and password created earlier.

Install these essential plugins:

  • Redis Object Cache

  • LiteSpeed Cache (if using OpenLiteSpeed)

  • WooCommerce

  • UpdraftPlus (backups)

  • WordFence (security)

  • Query Monitor (debugging)

11. Repeat for Multiple Sites

  • Clone the same setup for each site (site2.com, etc.)

  • Separate databases and folders (/var/www/site2.com)

  • Separate NGINX config

  • Separate SSL setup

  • Optional: Use panel like CloudPanel if you want UI-based management

Optional: Install CloudPanel (if you want GUI)

If you prefer managing WordPress from a panel, install:

curl -sS https://installer.cloudpanel.io/ce/v2/install.sh | sudo bash
0
Subscribe to my newsletter

Read articles from LingarajTechhub All About Programming directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

LingarajTechhub All About Programming
LingarajTechhub All About Programming

Corporate Software Development Trainer with a demonstrated track record of success in the IT and Ed-tech industries for product development. I started my career as a software developer and have since taught C, C++, Java, and Python to hundreds of IT enthusiasts, including corporate professionals, throughout the years. I have been developing software for over 12 years.