Learn to configure Apache/Nginx, set up DNS, and isolate sites on a single VPS so you can launch and manage dozens of domains yourself
Before We Start: What Youâll Walk Away With
By the time you finish this guide youâll be able to add a fresh domain to your VPS in under five minutes, just like ordering a coffee and getting it right away.
Youâll know exactly when to use a virtual host versus a container or a classic sharedâhosting setupâthink of it as choosing between a singleâroom apartment, a studio loft, or a fullâhouse rental depending on how much privacy each client needs.
Next, youâll have a working Apache or Nginx configuration that serves any number of sites from the same server, similar to how Google Maps can display countless pins without slowing down.
Finally, youâll walk away with a concise checklist that guarantees each site stays isolated and secure, like packing separate zipâlock bags for different foods to avoid crossâcontamination.
Identify the right isolation method: virtual host, container, or shared hosting.
Set up the web server: edit
apache2.confornginx.confto add new host blocks.Apply the security checklist: permissions, firewalls, SSL, and backups.
Virtual hosts: lightweight, perfect for dozens of lowâtraffic sites.
Containers: add a full OS sandbox when a client needs custom software.
Shared hosting style: use when you want a quick, throwâaway test site.
Checklist:
Create a dedicated system user for each domain.
Set file ownership to that user.
Generate a free
Let's Encryptcertificate.Open only required ports in
ufw.
With these tools in hand, hosting multiple websites on one VPS becomes a routine task, not a puzzle.
What Hosting Multiple Websites on One VPS Actually Is (No Jargon)
Hosting multiple websites on one VPS means you run several independent webâapplications on the same physical server, each pointed to its own folder by a virtualâhost configuration. The serverâs resourcesâCPU, RAM, diskâare shared, but the sites stay isolated because the web server knows which files belong to which domain.
Think of a VPS as an office building and each website as a separate office. The building (the server) stays the same, but every office (site) has its own door (domain) and lock (config file). Visitors use the address on the door to get inside, and the security system makes sure they canât wander into a neighboring office.
The 4 Mistakes Everyone Makes With MultiâSite VPS Setups
Most people ruin their multiâsite VPS before they even finish the first deployment.
Overwriting the default virtual host â Think of it like changing the address on the front door of your house; every visitor now ends up at the wrong place. When you replace the default
000-default.confwith a new siteâs config, the original site disappears. Keep the original file untouched and create a separate.conffor each domain.Sharing one document root â Imagine stuffing every clientâs luggage into the same suitcase; items collide and get lost. Using
/var/www/htmlfor all domains meansindex.htmlfrom one site overwrites another. Assign a unique folder, e.g.,/var/www/site1,/var/www/site2, and point each virtual host there.Skipping the reload/restart step â Itâs like ordering food and never telling the kitchen itâs ready; the meal never arrives. After editing
.conffiles, runsudo systemctl reload nginx(orapache2) so the server reads the new settings.
Ignoring fileâsystem permissions â Think of leaving every drawer unlocked in a shared apartment; anyone can rummage through anyone elseâs stuff. Set proper ownership and permissions, for example:
sudo chown -R www-data:www-data /var/www/site1sudo chmod -R 750 /var/www/site1
This keeps each siteâs files isolated and blocks crossâsite attacks.
Fix these four pitfalls and youâll get a clean, secure environment for hosting multiple websites on one VPS.
How to Host Multiple Websites on One VPS: StepâbyâStep
Refresh the system and pull in your web server. Think of it like updating the kitchen before cooking:
apt-get update && apt-get install nginx
Lay out a separate folder for each site under /var/www. Itâs like assigning a different drawer for every clientâs paperwork:
mkdir -p /var/www/site1.com
Set the folder ownership so the web server can read the files. This is the âhandâoffâ to the kitchen staff:
chown -R www-data:www-data /var/www/site1.com
Create a server block for the domain. Imagine giving the delivery driver a map that points straight to the right doorstep:
nano /etc/nginx/sites-available/site1.com
server {
listen 80;
server_name site1.com www.site1.com;
root /var/www/site1.com;
index index.html;
}
Then enable it:
ln -s /etc/nginx/sites-available/site1.com /etc/nginx/sites-enabled/
- Tell the world where to find the site. Sarah, a freelance photographer, adds an Aârecord for
photoâstudio.comthat points to203.0.113.45in her registrarâs DNS panel.
Check the config for syntax errors and reload. Itâs like tasting the sauce before serving:
nginx -t && systemctl reload nginx
Secure the site with a free certificate. Think of it as sealing the envelope with a tamperâproof sticker:
certbot --nginx -d site1.com -d www.site1.com
Optional: Add a firewall rule if you want traffic to a specific site to stay on its own lane. Example with ufw:
ufw allow from 203.0.113.0/24 to any port 80 comment 'site1.com traffic'
A Real Example: Janeâs Portfolio & Client Blog on a Single VPS
Jane spins up a $10/mo VPS and wants her showcase at portfolio.janedoe.com and a clientâs blog at blog.clientx.com on the same machine.
Log in and create two web roots:
sudo mkdir -p /var/www/portfolio.janedoe.com/public_html
sudo mkdir -p /var/www/blog.clientx.com/public_html
Assign ownership to the www-data user:
sudo chown -R www-data:www-data /var/www/portfolio.janedoe.com
sudo chown -R www-data:www-data /var/www/blog.clientx.com
Copy a simple index file into each folder (think of packing a suitcase with just the essentials):
Jane Doe â Designer
Welcome to my portfolio.
Client X Blog
Latest updates from Client X.
Create two Nginx server blocks, one for each domain (like ordering two separate meals from the same kitchen):
sudo tee /etc/nginx/sites-available/portfolio.janedoe.com > /dev/null /dev/null
Enable the blocks and reload Nginx:
bash
sudo ln -s /etc/nginx/sites-available/portfolio.janedoe.com /etc/nginx/sites-enabled/
sudo ln -s /etc/nginx/sites-available/blog.clientx.com /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
Obtain free SSL certificates with Certbot (think of wrapping each site in a safety blanket):
bash
sudo certbot --nginx -d portfolio.janedoe.com -d www.portfolio.janedoe.com
sudo certbot --nginx -d blog.clientx.com -d www.blog.clientx.com
- Verify DNS points to the VPS IP for both domains (like setting the right address on a Google Maps pin).
- Test both URLs; each loads its own content over HTTPS and runs in its own directory.
Result: Janeâs portfolio and the clientâs blog are live, each secured with HTTPS, and completely isolated from one another on the same VPS.
## The Tools That Make This Easier
First, grab the utilities that will keep your multiâsite VPS tidy and secure.
- Install **Certbot** and let it autoârenew Letâs Encrypt certificates. Think of it as a coffee subscription that never runs outâonce set, you never worry about it again.
- Deploy **Cockpit** for a graphical view of your virtual hosts. Itâs like ordering food from a menu instead of typing every dishâs ingredients.
- Enable **Fail2Ban** to block repeated login attempts. Picture a bouncer that recognizes the same troublemaker and keeps them out without you lifting a finger.
- Configure **UFW** as the frontâdoor firewall. Itâs the simple lock on your suitcase that you can set per site, so one domainâs rules donât affect another.
- Set up **GitâDeploy** to push code straight into `/var/www`. Imagine mailing a package that lands exactly where you need it, no unpacking required.
- **Certbot** â free client, runs `certbot renew` via cron, works with Nginx and Apache.
- **Cockpit** â web UI at `:9090`, edit `/etc/nginx/sitesâavailable` with a click.
- **Fail2Ban** â default jail for SSH, add `nginxâauth` to protect each siteâs login.
- **UFW** â simple commands like `ufw allow from 203.0.113.0/24 to any port 80` to isolate traffic.
- **GitâDeploy** â drop a `post-receive` hook into `~/.ssh/authorized_keys` to autoâcopy a repo into the site folder.
With these tools in place, hosting multiple websites on one VPS becomes as painless as packing a suitcase with preâsorted compartments.
## Quick Reference: MultiâSite VPS Cheat Sheet
Grab a pen and follow these biteâsize actions to keep every site tidy on a single VPS.
- Refresh the OS and pull in your web server: `apt update && apt install nginx` (or `apache2` if you prefer).
- Make a folder for each domain, e.g. `mkdir -p /var/www/example.com`. Think of it like assigning a separate drawer for each clientâs paperwork.
- Give the webâuser ownership so the server can read and write: `chown -R www-data:www-data /var/www/example.com`.
- Create a server block (nginx) or virtual host (Apache) that points the domain to its folder. Itâs the map that tells traffic which suitcase to open.
- Update DNS: set the **Aârecord** of `example.com` to your VPS IP. *Maria, a freelance designer, does this in her domain registrarâs panel and the domain instantly knows where to go.*
- Validate the config â `nginx -t` or `apachectl configtest`. Itâs the quick âdoes the recipe smell right?â check before you bake.
- Reload the service so changes take effect: `systemctl reload nginx` (or `apache2`).
- Secure the site with Letâs Encrypt: `certbot --nginx -d example.com`. One command, automatic renewals, no extra paperwork.
- **Optional**: tighten access with a firewall rule, e.g. `ufw allow from 203.0.113.0/24 to any port 22` for SSH.
- **Tip**: Keep a master `sites-available` list; copy it when you add a new site.
- **Tip**: Test each domain locally with `curl -I http://example.com` before DNS propagates.
Follow this cheat sheet and youâll host multiple websites on one VPS without breaking a sweat.
## What to Do Next
Give it a quick test drive: add a second domain just like you did for the first, then pop it in the browser.
- **Easy** â Create a new `example2.com` config in `/etc/nginx/sitesâavailable`, link it, reload Nginx, and point the DNS to your VPS. Itâs like ordering a second coffee after the first â same process, fresh result.
- **Medium** â Set up automated backups. A nightly `rsync` job or a Borg repository will copy each siteâs `/var/www` folder to a safe location. Think of it as packing a spare suitcase for a trip; youâll thank yourself if anything gets lost.
- **Hard** â Containerize every site with Docker Compose. Write a `dockerâcompose.yml` that spins up an isolated Nginx, PHP, and DB container per domain while sharing the hostâs network. This gives you the isolation of separate apartments in the same building.
- **Tip:** Keep a `backup.sh` script versionâcontrolled so you can recreate any site with one command.
- **Tip:** Use `dockerâcompose logs` to troubleshoot container issues without digging through host logs.
Got a unique multiâsite setup or ran into a snag? Drop a comment below â Iâd love to help!
---
---
## About the Author
**[Abdullah Sheikh](https://abdullah-sheikh.com/)** is the Founder & CEO at [Exteed](https://exteed.com/), where he leads a team of skilled developers specializing in [Web2](https://abdullah-sheikh.com/) and [Web3 applications](https://abdullah-sheikh.com/), [Custom Smart Contracts](https://abdullah-sheikh.com/), and [Blockchain solutions](https://abdullah-sheikh.com/).
With 6+ years of experience, Abdullah has built [CRMs](https://abdullah-sheikh.com/), [Crypto Wallets](https://abdullah-sheikh.com/), [DeFi Exchanges](https://abdullah-sheikh.com/), [E-Commerce Stores](https://abdullah-sheikh.com/), [HIPAA Compliant EMR Systems](https://abdullah-sheikh.com/), and [AI-powered systems](https://abdullah-sheikh.com/) that drive business efficiency and innovation.
His expertise spans [Blockchain](https://abdullah-sheikh.com/), [Crypto & Tokenomics](https://abdullah-sheikh.com/), [Artificial Intelligence](https://abdullah-sheikh.com/), and [Web Applications](https://abdullah-sheikh.com/); building reliable and smooth web apps that fit the clientâs goals and requirements.
đ§ [info@abdullah-sheikh.com](mailto:info@abdullah-sheikh.com) ¡ đ [LinkedIn](https://www.linkedin.com/in/-abdullah-sheikh/) ¡ đ [abdullah-sheikh.com](https://abdullah-sheikh.com/)
Top comments (0)