How to host multiple websites on one VPS
One VPS can serve many domains. Learn how virtual hosts (server blocks) work in Nginx, how to add each site, and how to give every domain its own free SSL.
One of the best things about a VPS is that a single server can host many websites at once — each with its own domain, files and SSL certificate. The mechanism is name-based virtual hosting, called server blocks in Nginx. Here's how to set it up cleanly.
How it works
When a browser requests a page, it sends the domain name in the request's Host header. Nginx reads that header and routes the request to the matching site configuration. So site-a.com and site-b.com can share one IP, one Nginx, and one VPS, yet serve completely separate content.
Step 1: Install Nginx
On a fresh Ubuntu or Debian VPS:
sudo apt update
sudo apt install nginx -y
Open the firewall for web traffic:
sudo ufw allow 'Nginx Full'
Step 2: Create a folder for each site
Give every website its own document root:
sudo mkdir -p /var/www/site-a.com/html
sudo mkdir -p /var/www/site-b.com/html
sudo chown -R $USER:$USER /var/www/site-a.com/html /var/www/site-b.com/html
Drop a test page in each:
echo "<h1>Site A</h1>" > /var/www/site-a.com/html/index.html
echo "<h1>Site B</h1>" > /var/www/site-b.com/html/index.html
Step 3: Write a server block per site
Create /etc/nginx/sites-available/site-a.com:
server {
listen 80;
server_name site-a.com www.site-a.com;
root /var/www/site-a.com/html;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}
Make a matching file for site-b.com, changing the domain and root path. Keeping one file per site is what makes this tidy at scale.
Step 4: Enable the sites
Nginx serves any config symlinked into sites-enabled:
sudo ln -s /etc/nginx/sites-available/site-a.com /etc/nginx/sites-enabled/
sudo ln -s /etc/nginx/sites-available/site-b.com /etc/nginx/sites-enabled/
Test the configuration and reload:
sudo nginx -t
sudo systemctl reload nginx
Step 5: Point the domains at your VPS
At your DNS provider, create an A record for each domain pointing to your VPS IP. Include www too. DNS can take a little while to propagate; once it does, each domain loads its own page.
Step 6: Add free SSL to every site
Certbot issues and configures Let's Encrypt certificates automatically:
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d site-a.com -d www.site-a.com
sudo certbot --nginx -d site-b.com -d www.site-b.com
Certbot edits each server block to serve HTTPS and sets up automatic renewal. Run sudo certbot renew --dry-run to confirm renewals will work.
Scaling up
The same pattern extends to as many sites as your resources allow — just add a folder, a server block and a DNS record for each. Watch your RAM and CPU as you go; a modest VPS comfortably serves several small sites, and if you outgrow it you can resize the plan.
Prefer a control panel?
Doing this by hand is great for learning and for a handful of sites. If you'd rather point-and-click, a panel like CyberPanel or HestiaCP manages virtual hosts, databases and SSL for dozens of sites through a web UI — both available as one-click images on Nxeon. Under the hood they're doing exactly what you just did manually.
The takeaway
Multiple websites on one VPS comes down to one idea: a server block per domain, each with its own root and certificate. Set the pattern once and adding the next site takes two minutes.