How to Run Multiple Websites on One VPS in Bangladesh
SNBD Host Team
One of the biggest advantages of a VPS over shared hosting is that you control how many websites run on it. Instead of paying separate shared hosting fees for each site, you can host dozens of websites on a single VPS — with independent SSL certificates, separate databases, and proper isolation.
This guide shows you how to set up multiple websites on a BDIX VPS using Nginx server blocks (virtual hosts). The same approach works on a Singapore VPS or USA VPS.
Understanding Virtual Hosts (Server Blocks)
When someone types site1.com in their browser, the request reaches your VPS's IP address. Nginx reads the Host header in the request to determine which website to serve — even though multiple sites share the same IP.
Each website gets its own server block — a configuration file that tells Nginx: "when someone requests this domain, serve files from this directory."
Prerequisites
- A VPS with Ubuntu 22.04 (this guide uses SNBD HOST BDIX VPS)
- Nginx installed
- Root or sudo access
- Domain names pointing to your VPS IP (via A records in your DNS provider)
If you haven't set up your VPS yet, follow our VPS beginner setup guide first.
Directory Structure
Create a clean directory structure for your sites:
sudo mkdir -p /var/www/site1.com/html
sudo mkdir -p /var/www/site2.com/html
sudo mkdir -p /var/www/site3.com/html
Set ownership so your user can manage files without sudo:
sudo chown -R $USER:$USER /var/www/site1.com
sudo chown -R $USER:$USER /var/www/site2.com
sudo chown -R $USER:$USER /var/www/site3.com
Create a test page for site1:
nano /var/www/site1.com/html/index.html
<h1>Site 1 is working</h1>
Repeat for each site with different content so you can verify which site is loading.
Creating Nginx Server Blocks
Server Block for site1.com
sudo nano /etc/nginx/sites-available/site1.com
server {
listen 80;
listen [::]:80;
server_name site1.com www.site1.com;
root /var/www/site1.com/html;
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:/run/php/php8.1-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /.ht {
deny all;
}
access_log /var/log/nginx/site1.com.access.log;
error_log /var/log/nginx/site1.com.error.log;
}
Server Block for site2.com
sudo nano /etc/nginx/sites-available/site2.com
server {
listen 80;
listen [::]:80;
server_name site2.com www.site2.com;
root /var/www/site2.com/html;
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:/run/php/php8.1-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
access_log /var/log/nginx/site2.com.access.log;
error_log /var/log/nginx/site2.com.error.log;
}
Enable the Sites
Create symlinks in sites-enabled:
sudo ln -s /etc/nginx/sites-available/site1.com /etc/nginx/sites-enabled/
sudo ln -s /etc/nginx/sites-available/site2.com /etc/nginx/sites-enabled/
Test the configuration and reload:
sudo nginx -t
sudo systemctl reload nginx
Adding SSL for Each Site
Each domain gets its own free SSL certificate from Let's Encrypt:
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d site1.com -d www.site1.com
sudo certbot --nginx -d site2.com -d www.site2.com
sudo certbot --nginx -d site3.com -d www.site3.com
Certbot automatically modifies your Nginx config to redirect HTTP to HTTPS and adds SSL directives. It also sets up automatic renewal via a cron job.
Setting Up Separate Databases
For WordPress or PHP sites that need databases, create a separate database and user per site:
sudo mysql -u root -p
CREATE DATABASE site1_db;
CREATE USER 'site1_user'@'localhost' IDENTIFIED BY 'strongpassword1';
GRANT ALL PRIVILEGES ON site1_db.* TO 'site1_user'@'localhost';
CREATE DATABASE site2_db;
CREATE USER 'site2_user'@'localhost' IDENTIFIED BY 'strongpassword2';
GRANT ALL PRIVILEGES ON site2_db.* TO 'site2_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Each site has its own database user with access only to its own database. A vulnerability in site1 can't read site2's database.
Installing WordPress per Site
For each WordPress site:
cd /var/www/site1.com/html
wget https://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz --strip-components=1
rm latest.tar.gz
cp wp-config-sample.php wp-config.php
Edit wp-config.php with your database credentials:
nano wp-config.php
define('DB_NAME', 'site1_db');
define('DB_USER', 'site1_user');
define('DB_PASSWORD', 'strongpassword1');
define('DB_HOST', 'localhost');
Set correct file ownership:
sudo chown -R www-data:www-data /var/www/site1.com/html
sudo find /var/www/site1.com/html -type d -exec chmod 755 {} ;
sudo find /var/www/site1.com/html -type f -exec chmod 644 {} ;
Visit https://site1.com and complete the WordPress installation wizard.
How Many Sites Can One VPS Handle?
The answer depends on traffic, not the number of sites. Here's a realistic breakdown for SNBD HOST VPS tiers:
- 1 vCPU / 1 GB RAM (৳499/mo): 5–10 low-traffic WordPress sites (under 500 visitors/day each)
- 2 vCPU / 2 GB RAM: 15–25 sites, or 5–8 medium-traffic sites
- 4 vCPU / 4 GB RAM: 40+ sites comfortably, or several high-traffic sites
NVMe SSD storage (standard on SNBD HOST VPS) means disk I/O isn't a bottleneck — RAM and CPU are what you run out of first with WordPress sites.
Using PHP-FPM Pools for Better Isolation
By default, all PHP sites share one PHP-FPM pool running as www-data. For stronger isolation between client sites, create separate pools:
sudo cp /etc/php/8.1/fpm/pool.d/www.conf /etc/php/8.1/fpm/pool.d/site1.conf
sudo nano /etc/php/8.1/fpm/pool.d/site1.conf
Change these values:
[site1]
user = site1
group = site1
listen = /run/php/php8.1-fpm-site1.sock
listen.owner = www-data
listen.group = www-data
Create the system user:
sudo useradd -M -s /bin/false site1
Update site1's Nginx config to use the dedicated socket:
fastcgi_pass unix:/run/php/php8.1-fpm-site1.sock;
This means each site's PHP runs under a different system user — a PHP vulnerability on one site can't access another site's files.
Managing Multiple Sites Efficiently
Centralized Log Monitoring
With per-site log files, you can monitor all sites easily:
# Watch all error logs in real-time
tail -f /var/log/nginx/*.error.log
Per-Site Backup Script
#!/bin/bash
DATE=$(date +%Y%m%d)
for site in site1.com site2.com site3.com; do
tar -czf /backups/${site}_${DATE}.tar.gz /var/www/${site}
done
mysqldump site1_db > /backups/site1_db_${DATE}.sql
mysqldump site2_db > /backups/site2_db_${DATE}.sql
Checking Nginx Config After Changes
Always test before reloading:
sudo nginx -t && sudo systemctl reload nginx
Cost Comparison: VPS vs Multiple Shared Hosting Plans
If you're managing websites for clients or running multiple projects in Bangladesh:
- 5 separate shared hosting plans at ৳250/mo each = ৳1,250/mo
- One VPS hosting all 5 sites = ৳499–999/mo
The VPS option is significantly cheaper and gives you far more control. As the number of sites grows, the cost advantage of a single BDIX VPS over separate shared plans compounds quickly.
The setup takes a few hours upfront. After that, adding a new site takes about 10 minutes: create the directory, create the server block, run Certbot, create the database. That's a one-time learning investment that saves money every month indefinitely.