The Short Answer
One VPS can host many websites — that is one of the main reasons to own a server instead of paying per-site shared hosting. Nginx decides which site to serve by reading the domain name in each request (a “server block” per site), so ten domains on one IP address each get their own files, their own database and their own SSL certificate. This guide sets up a second site alongside an existing one on Ubuntu 24.04, with the isolation practices that stop one site’s problems from taking down the others.
This guide assumes Nginx is already installed with at least one working site. If you are starting from scratch, How to Install WordPress on a VPS covers the first-site setup, and How to Point a Domain to Your VPS covers the DNS side — each additional domain needs its own A record pointing at the same server IP.
How Virtual Hosting Works
When a browser requests https://siteb.com, it sends the hostname in the HTTP Host header (and in the TLS handshake, via SNI). Nginx reads that name and matches it against its server blocks: the request goes to whichever block lists siteb.com as its server_name. If no block matches, Nginx serves the default block — which is why a misconfigured server sometimes shows the wrong site.
Nothing about this requires extra IP addresses, extra ports or extra servers. One IP, one Nginx, many sites. The practical limits are resources (RAM, CPU, disk) and your own organisation — which is what the rest of this guide is about.
Step 1: Point the New Domain at the Server
Before touching Nginx, create the DNS records for the new domain, exactly as for the first site:
| Type | Host | Value | TTL |
|---|---|---|---|
| A | @ | YOUR_SERVER_IP | 300 |
| CNAME | www | yourdomain.com | 300 |
Wait until dig newdomain.com +short returns your server’s IP. Nginx configuration can be prepared in advance, but SSL issuance (Step 5) must wait for DNS.
Step 2: Create the Site’s Directory and Files
Give each site its own directory under /var/www, named after the domain. This separation is the foundation of everything else — permissions, backups, and debugging all assume it.
sudo mkdir -p /var/www/newsite.com/html
sudo chown -R www-data:www-data /var/www/newsite.com
sudo chmod -R 755 /var/www/newsite.com
Drop in a placeholder page to test with:
echo "<h1>newsite.com works</h1>" | sudo tee /var/www/newsite.com/html/index.html
For a WordPress site, install WordPress into /var/www/newsite.com/html instead — the procedure is the same as the first site, with a different directory and a different database (Step 4).
Step 3: Create the Nginx Server Block
Each site gets its own configuration file in /etc/nginx/sites-available/, symlinked into /etc/nginx/sites-enabled/. Never edit the default file to add sites — one file per site keeps changes isolated and reversible.
sudo nano /etc/nginx/sites-available/newsite.com
A complete server block for a PHP site (WordPress or similar):
server {
listen 80;
listen [::]:80;
server_name newsite.com www.newsite.com;
root /var/www/newsite.com/html;
index index.php index.html index.htm;
access_log /var/log/nginx/newsite.com.access.log;
error_log /var/log/nginx/newsite.com.error.log;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.3-fpm-newsite.sock;
}
location ~ /\.ht {
deny all;
}
}
Three details matter:
- Separate log files per site (
newsite.com.access.log,newsite.com.error.log). Shared logs make debugging a multi-site server miserable — when one site errors, you want its log, not a merged stream of all sites. - A separate PHP-FPM socket per site (
php8.3-fpm-newsite.sock) — set up in Step 4. A shared PHP pool means one site’s runaway script consumes the PHP workers of every site. server_namelists both the root domain andwww. Requests for either name land here.
Enable the site and test the configuration:
sudo ln -s /etc/nginx/sites-available/newsite.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
Visit http://newsite.com — you should see the placeholder page. If you see the other site instead, Nginx matched the wrong block: check that server_name is exactly right and that the symlink exists.
Step 4: Isolate PHP and the Database Per Site
Isolation is what separates a professional multi-site server from a fragile one. Three separations matter:
Separate PHP-FPM pools
Create a pool configuration per site so each site has its own PHP workers, its own resource limits, and (with a dedicated user) its own file permissions:
sudo cp /etc/php/8.3/fpm/pool.d/www.conf /etc/php/8.3/fpm/pool.d/newsite.conf
sudo nano /etc/php/8.3/fpm/pool.d/newsite.conf
Change these lines:
[newsite]
user = www-data
group = www-data
listen = /run/php/php8.3-fpm-newsite.sock
listen.owner = www-data
listen.group = www-data
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
Keep pm.max_children small per site — five children per site across four sites is 20 PHP processes, each using 30–60 MB. Size the total against your RAM; if the maths does not fit, the server needs more memory (see How to Upgrade Your VPS). Restart PHP-FPM after editing:
sudo systemctl restart php8.3-fpm
For stronger isolation (sites owned by different people, or untrusted code), create a separate Linux user per site and set the pool’s user to that account, with the site directory owned by the same user. Then a compromised site cannot read another site’s files. This is more setup, but it is the correct answer for hosting sites for clients.
Separate databases and users
Never share a database — or a database user — between sites. Each site gets its own database and a user with access only to that database:
sudo mysql
CREATE DATABASE newsite_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'newsite_user'@'localhost' IDENTIFIED BY 'a-strong-unique-password';
GRANT ALL PRIVILEGES ON newsite_db.* TO 'newsite_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
A shared database user is a real security hole: if one WordPress site is compromised, the attacker gets the credentials in its wp-config.php — and with a shared user, those credentials open every site’s database.
Separate backups
Back up each site’s files and database independently so you can restore one site without touching the others. Extend the restic script from How to Back Up Your VPS with per-site database dumps, or use a WordPress backup plugin per site for application-level restores.
Step 5: SSL for Each Site
Each site needs its own certificate (or one certificate covering several names). Certbot handles this per site — run it once per domain:
sudo certbot --nginx -d newsite.com -d www.newsite.com
Certbot detects the matching server block, adds the SSL configuration, and sets up the HTTP redirect. Repeat for each new site. Renewal is automatic for all certificates at once via the certbot timer — verify with sudo certbot renew --dry-run after adding sites.
Alternatively, a single certificate can cover multiple domains (-d sitea.com -d siteb.com), but per-site certificates are cleaner: renewing, revoking or moving one site does not affect the others. The full SSL walkthrough, including wildcard certificates, is in How to Set Up Free SSL with Let’s Encrypt on a VPS.
Step 6: Resource Planning — How Many Sites Fit?
There is no fixed number — it depends on the sites. A realistic guide for a 2 vCPU / 4 GB server:
| Site type | RAM per site (rough) | Sites on 4 GB |
|---|---|---|
| Static site / landing page | ~50 MB | Dozens |
| Small cached WordPress blog | ~150–250 MB | 8–12 |
| Active WordPress with WooCommerce | ~400–600 MB | 4–6 |
| WordPress + heavy plugins, uncached | ~600 MB+ | 2–3 |
These are rough planning figures, not measurements — check real usage with htop and per-site PHP-FPM status pages after a week of traffic. The warning signs of an overloaded server are the same as for a single site: high load average, swap use, and slow response times. How to Monitor Your VPS shows how to watch for them, and How to Speed Up Your VPS covers the caching that makes multi-site hosting viable on a small server — page caching is what turns “three sites” into “ten sites” on the same hardware.
If you are choosing a server specifically for multiple sites, Best Cheap VPS for Hosting Multiple Websites in 2026 compares the budget options, and Contabo’s Cloud VPS 4 (4 vCPU / 8 GB RAM, from €4.40/month on a 24-month term, checked 23 November 2026) is a strong value pick for a multi-site server.
Managing Sites Day to Day
Add a site: DNS → directory → server block → PHP pool → database → certbot. The sequence is the same every time; after the second site it takes about fifteen minutes.
Disable a site temporarily without deleting anything:
sudo rm /etc/nginx/sites-enabled/newsite.com
sudo nginx -t && sudo systemctl reload nginx
The configuration stays in sites-available/ and can be re-enabled with a new symlink. (Do not delete the sites-available file unless you mean to remove the site permanently.)
Remove a site permanently: remove both symlinks and config files, delete the directory and database, and revoke the certificate:
sudo rm /etc/nginx/sites-enabled/newsite.com /etc/nginx/sites-available/newsite.com
sudo rm -rf /var/www/newsite.com
sudo mysql -e "DROP DATABASE newsite_db; DROP USER 'newsite_user'@'localhost';"
sudo certbot delete --cert-name newsite.com
sudo systemctl reload nginx
Take a backup before deleting anything — “I deleted the wrong site” is a mistake you only want to make once.
Troubleshooting
“The new domain shows the first site’s content.” Nginx matched the wrong server block. Causes: the new block’s server_name has a typo, the symlink in sites-enabled/ is missing, or Nginx was not reloaded. Run sudo nginx -T to dump the effective configuration and check which blocks exist and what names they claim. Also check for a default_server flag on the first site’s listen line — the default block catches all unmatched requests.
“The new site returns 403 Forbidden.” File permissions. The web server user (www-data) must be able to read the site directory: sudo chown -R www-data:www-data /var/www/newsite.com and sudo chmod -R 755 /var/www/newsite.com. Also check that an index.php or index.html exists — a directory with no index file returns 403.
“502 Bad Gateway on the new site only.” PHP-FPM is not listening on the socket the server block expects. Confirm the pool is running (sudo systemctl status php8.3-fpm), that the socket file exists (ls /run/php/), and that the fastcgi_pass line in the server block matches the pool’s listen line exactly — a one-character mismatch produces a 502.
“One site is slow, the others are fine.” The problem is site-specific: a heavy plugin, an uncached page, or a slow database query on that site. Check its own error log (/var/log/nginx/newsite.com.error.log) and its PHP-FPM pool status. The per-site logs from Step 3 exist precisely for this moment.
“All sites went down after I edited one config.” A syntax error in any enabled server block prevents Nginx from reloading — sudo nginx -t catches this before reload, which is why you should always test before reloading. If Nginx is already down, sudo nginx -t names the file and line number; fix it and reload.
“Certbot modified the wrong server block.” Certbot matches certificates to blocks by server_name. If two blocks claim the same name (a leftover duplicate), certbot edits the first match. Keep server_name unique across all blocks and remove stale configuration files.
Frequently Asked Questions
How many websites can I host on one VPS?
As many as the resources allow. Static sites are nearly free; cached WordPress blogs cost roughly 150–250 MB of RAM each; heavy uncached sites cost far more. A 4 GB server comfortably hosts 8–12 small cached sites. The real limit is usually RAM, then CPU during traffic spikes.
Do I need a separate IP address for each website?
No. Modern servers use SNI (Server Name Indication) to serve different SSL certificates for different domains on a single IP address. Separate IPs per site were necessary in the pre-SNI era; today, one IP handles unlimited sites.
Can I mix WordPress and non-WordPress sites on one server?
Yes. Each server block is independent — one can serve WordPress with PHP-FPM, another a static HTML site, another a Node.js app via reverse proxy. The only shared pieces are Nginx itself and the server’s resources.
Should each site have its own PHP-FPM pool?
Yes, for anything beyond a couple of trivial sites. Separate pools isolate crashes and resource hogs: one site’s runaway script exhausts its own five workers instead of all of them. The cost is a small amount of extra memory per pool.
What happens if one site gets hacked — are the others at risk?
With shared www-data ownership and a shared database user, yes — a compromise of one site can reach the others’ files and databases. With per-site Linux users, per-site PHP pools and per-site database users, the blast radius is contained to the compromised site. Match the isolation level to the trust level: your own sites can share more; client sites should be fully separated.
Is it better to host many sites on one big VPS or one site per small VPS?
One big VPS is cheaper and simpler to manage (one server to update, monitor and back up). Separate VPSs give stronger isolation and independent scaling — a traffic spike on one site cannot affect the others at all. For personal projects and small client sites, one well-organised server wins. For sites with different owners, compliance needs, or very different traffic patterns, separation wins.
The Bottom Line
One server block, one directory, one PHP pool and one database per site — that is the whole pattern, repeated for each domain. Keep the isolation discipline and the per-site logs, size the server against real memory use, and a single VPS becomes a quiet, cheap home for a whole portfolio of sites.



Leave a Reply