WordPress Multisite on a VPS: Network Setup, Domain Mapping, and Shared Hosting Migration

WordPress Multisite on a VPS: Network Setup, Domain Mapping, and Shared Hosting Migration

WordPress Multisite allows running hundreds of WordPress sites from a single installation — sharing core files, plugins, themes, and PHP processes, but with independent content, settings, and user databases. Running Multisite on a VPS gives you complete control over network policies, plugin activation, user registration, and storage quotas without per-site hosting costs. This guide sets up a Multisite network with wildcard subdomain mode and custom domain mapping.

Multisite Network Types

  • Subdomain: site1.yourdomain.com, site2.yourdomain.com — requires wildcard DNS and SSL. Cleanest URL structure.
  • Subdirectory: yourdomain.com/site1/, yourdomain.com/site2/ — simpler DNS. Better for existing single-site WordPress installations.
  • Custom domains: client1.com, client2.com — each site on its own domain. Best for agency work.

This guide uses subdomain mode with custom domain mapping — the most flexible and professional configuration.

Step 1: DNS — Wildcard Record

# At your DNS provider, add a wildcard A record pointing to your VPS IP:
*.yourdomain.com    IN    A    YOUR_VPS_IP
yourdomain.com      IN    A    YOUR_VPS_IP

Step 2: Enable WordPress Multisite

Start with a working single-site WordPress installation. Then add to wp-config.php (before the “That’s all” line):

/* Enable Multisite Network */
define( 'WP_ALLOW_MULTISITE', true );
  1. Visit WordPress Admin → Tools → Network Setup
  2. Choose Sub-domains
  3. Click Install — WordPress shows two code blocks to add to wp-config.php and .htaccess
  4. Follow the on-screen instructions exactly

After setup, your wp-config.php will include:

define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', true);
define('DOMAIN_CURRENT_SITE', 'yourdomain.com');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

Step 3: Nginx Configuration for Multisite

sudo nano /etc/nginx/sites-available/wordpress-multisite
upstream php-handler {
    server unix:/var/run/php/php8.2-fpm.sock;
}

server {
    listen 80;
    server_name .yourdomain.com;   # Leading dot matches all subdomains
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl http2;
    server_name .yourdomain.com;   # Wildcard — matches all subdomains

    root /var/www/wordpress;
    index index.php;

    # Wildcard SSL certificate (configured in Step 4)
    ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;

    client_max_body_size 256M;

    # WordPress Multisite: serve uploaded files per-blog
    location ~ ^/files/(.*)$ {
        try_files /wp-content/blogs.dir/$blogid/$uri /wp-includes/ms-files.php?file=$1;
        access_log off;
        log_not_found off;
        expires max;
    }

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

    # WordPress Multisite rewrite rules for subdomain installs
    if (!-e $request_filename) {
        rewrite /wp-admin$ $scheme://$host$uri/ permanent;
        rewrite ^(/[^/]+)?(/wp-.*) $2 last;
        rewrite ^(/[^/]+)?(/.*\.php) $2 last;
    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass php-handler;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param HTTPS on;
    }

    location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff2|webp)$ {
        expires max;
        add_header Cache-Control "public, immutable";
        access_log off;
    }
}
sudo ln -s /etc/nginx/sites-available/wordpress-multisite /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx

Step 4: Wildcard SSL Certificate

Wildcard certificates require DNS challenge (not HTTP challenge). Using Cloudflare DNS:

pip install certbot-dns-cloudflare

mkdir -p ~/.secrets/certbot
nano ~/.secrets/certbot/cloudflare.ini
dns_cloudflare_api_token = your_cloudflare_api_token
chmod 600 ~/.secrets/certbot/cloudflare.ini

sudo certbot certonly \
    --dns-cloudflare \
    --dns-cloudflare-credentials ~/.secrets/certbot/cloudflare.ini \
    -d yourdomain.com \
    -d "*.yourdomain.com"

Step 5: Add Sites to the Network

  1. In the WordPress toolbar: My Sites → Network Admin → Dashboard
  2. Sites → Add New
  3. Site Address: site1 → creates site1.yourdomain.com
  4. Set site title and admin email
  5. Click Add Site

Step 6: Custom Domain Mapping

To map client1.com to a network site:

  1. At the client’s DNS: add an A record pointing to your VPS IP: client1.com → YOUR_VPS_IP
  2. In Network Admin → Sites → find the target site → Edit
  3. Change “Site Address (URL)” to https://client1.com
  4. Issue a certificate for the custom domain: sudo certbot --nginx -d client1.com -d www.client1.com
  5. Add a new Nginx server block for the custom domain (same configuration as the main block but with server_name client1.com www.client1.com)

Step 7: Network Plugin and Theme Management

# Using WP-CLI to manage the network

# Activate a plugin network-wide (available to all sites)
wp plugin activate jetpack --network --allow-root --path=/var/www/wordpress

# Install and activate a theme network-wide
wp theme install astra --allow-root --path=/var/www/wordpress
wp theme enable astra --network --allow-root --path=/var/www/wordpress

# List all sites in the network
wp site list --allow-root --path=/var/www/wordpress

# Flush cache on all sites at once
wp site list --field=url --allow-root --path=/var/www/wordpress | \
    xargs -I {} wp --allow-root --url={} cache flush --path=/var/www/wordpress

Getting Started

WordPress Multisite on a VPS with 20+ sites runs well on 4 GB RAM — shared OPcache, a shared PHP-FPM pool, and shared MariaDB serve all sites efficiently from one set of processes. Ubuntu VPS plans at VPS.DO with NVMe storage handle media uploads and database queries across many sites without the I/O bottlenecks that affect HDD-backed hosting.

Conclusion

WordPress Multisite on a VPS is the most cost-efficient way to manage tens or hundreds of WordPress sites — shared core files, plugins, and PHP processes serve all sites at a fraction of per-site hosting cost. Subdomain mode with wildcard SSL and custom domain mapping gives each site a professional custom domain while all sites run from one installation on one VPS. For agencies charging $5–$20/month per client site, Multisite on a $20–$40/month VPS makes the economics work at any scale.

Fast • Reliable • Affordable VPS - DO It Now!

Get top VPS hosting with VPS.DO’s fast, low-cost plans. Try risk-free with our 7-day no-questions-asked refund and start today!