Your fourth client just signed. Your fourth hosting invoice lands next week. Meanwhile, your VPS idles at 6% CPU, doing almost nothing.
That gap has a cheap fix. You can host multiple websites on a VPS you already pay for. Each site gets its own domain, folder, Linux user, and SSL certificate.
This guide takes you from DNS records to live, secured sites. It uses Ubuntu LTS, Nginx, PHP-FPM, and Certbot.
You need sudo access and one domain per site. Set aside an hour or two for the first site. After that, each new site takes only a few minutes.
Table of Contents
What You Need Before You Host Multiple Websites on One VPS
Yes, one VPS can serve many websites. No software limit stops you. Hardware sets the ceiling, and the FAQs show how to measure it.
Start with a sensible baseline. A VPS with 2 GB of RAM, 1 vCPU, and 40 GB of storage handles a few small sites. WordPress-heavy sites need more memory.
Gather these items first:
- A VPS running a current Ubuntu LTS release.
- A
sudouser with SSH key login. - One registered domain for each site.
- Access to each domain’s DNS settings at the registrar.
This guide uses Nginx. Apache users get an equivalent config in Step 4. If you prefer a control panel, jump to the panel section near the end.
How One VPS Serves Many Domains with Name-Based Virtual Hosting
Every browser request carries the domain name the visitor typed. Nginx reads that name and picks the matching server block. Each block points to its own folder. That method is called name-based virtual hosting.

Do you need a separate IP address for each domain? Usually, no. All your domains can point to the same IP. For HTTPS, the browser sends the domain name during the TLS handshake. That feature is called SNI, and modern browsers all support it.
Two other methods exist. IP-based hosting needs one IP per site. Port-based hosting forces visitors to type port numbers. Neither suits public websites, so this guide skips both.
Step 1: Point Each Domain to Your VPS with DNS A Records
Log in to each domain’s DNS panel. Create A records that point to your VPS’s IP address. Use the same IP for every domain.
Here is a sample record set for one domain. The IP is a documentation example.
| Type | Name | Value | TTL |
|---|---|---|---|
| A | @ | 203.0.113.10 | 300 |
| A | www | 203.0.113.10 | 300 |
| AAAA | @ | Your IPv6 address | 300 |
Add the AAAA row only if your VPS has an IPv6 address. A wrong AAAA record sends IPv6 visitors to the wrong place.
Lower the TTL to 300 seconds a day before you switch an existing site. Short TTLs make changes spread sooner. Then confirm the records with dig:
dig +short site1.com
dig +short www.site1.com
Both commands should print your VPS IP; if they don’t, wait and try again. Propagation can take minutes or a few hours.
You don’t have to wait to test. Use curl –resolve to fake the DNS answer from your laptop:
curl --resolve site1.com:80:203.0.113.10 http://site1.com
Another route is to add a line to your local hosts file:
203.0.113.10 site1.com www.site1.com
Delete that line after testing. Otherwise, your laptop ignores the real DNS records.
Step 2: Install Nginx and PHP-FPM on Ubuntu

Connect over SSH and update the package list. Then install Nginx and PHP-FPM with the usual extensions:
sudo apt update
sudo apt install nginx php-fpm php-mysql php-curl php-gd php-mbstring php-xml php-zip -y
Next, open the firewall. Allow SSH first. Otherwise, you lock yourself out.
sudo ufw allow OpenSSH
sudo ufw allow 'Nginx Full'
sudo ufw enable
Run php -v to see your PHP version. The examples use 8.3. Swap in your own version number wherever it appears.
Visit http://YOUR_VPS_IP in a browser. You should see the default Nginx welcome page. That page confirms the web server runs and the firewall lets traffic through.
The database server waits until Step 6. Static sites don’t need one.
Step 3: Create a Separate Directory and Linux User for Each Site

Give every site its own folder and its own system user. This setup keeps each site’s files away from the others. It also makes cleanup easy when a client leaves.
Run these commands for the first site:
sudo adduser --system --group --home /var/www/site1.com site1
sudo mkdir -p /var/www/site1.com/public_html
echo "site1.com works" | sudo tee /var/www/site1.com/public_html/index.html
sudo chown -R site1:www-data /var/www/site1.com
sudo find /var/www/site1.com -type d -exec chmod 750 {} \;
sudo find /var/www/site1.com -type f -exec chmod 640 {} \;
The owner is the site user. The group is www-data, the account Nginx runs as. Nginx reads files through that group. Other site users get no access at all.
Many guides use 755 and 644 instead. However, those values let every user on the server read your files. That includes wp-config.php and its database password.
Repeat the commands for site2.com with the user site2. Use short usernames without dots. Use 750 for any folder that Nginx never serves.
Each test page carries a unique message. When a browser displays “site2.com works“, you know Nginx selected the correct block.
Step 4: Write an Nginx Server Block for Each Domain

Create the config file:
sudo nano /etc/nginx/sites-available/site1.com
Paste this server block:
server {
listen 80;
listen [::]:80;
server_name site1.com www.site1.com;
root /var/www/site1.com/public_html;
index index.php index.html;
access_log /var/log/nginx/site1.com.access.log;
error_log /var/log/nginx/site1.com.error.log;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
The server_name line lists the domains this block answers. The root line points to the site’s folder. Separate log files per site make debugging far simpler.
Now enable the site and reload Nginx:
sudo ln -s /etc/nginx/sites-available/site1.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
Always run nginx -t first. It catches typos before they take every site offline.
Next, stop unknown hostnames from landing on a real site. Nginx falls back to a default server for any name it doesn’t recognize. That default might be one of your real sites. A catch-all block closes the gap.
sudo rm /etc/nginx/sites-enabled/default
sudo nano /etc/nginx/sites-available/00-catchall
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
return 444;
}
server {
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
ssl_reject_handshake on;
}
sudo ln -s /etc/nginx/sites-available/00-catchall /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
The 444 return code closes the connection without a response. The ssl_reject_handshake line needs Nginx 1.19.4 or newer. Ubuntu 24.04 meets that bar. Ubuntu 22.04 ships an older release, so skip the second block there.
Test the site in your browser. You should see “site1.com works“. Repeat this step for every extra domain.
Apache Virtual Hosts Equivalent
Apache users create /etc/apache2/sites-available/site1.com.conf instead:
<VirtualHost *:80>
ServerName site1.com
ServerAlias www.site1.com
DocumentRoot /var/www/site1.com/public_html
ErrorLog ${APACHE_LOG_DIR}/site1.com.error.log
CustomLog ${APACHE_LOG_DIR}/site1.com.access.log combined
</VirtualHost>
Then enable the site, disable the default, and reload:
sudo a2ensite site1.com.conf
sudo a2dissite 000-default.conf
sudo apache2ctl configtest
sudo systemctl reload apache2
The later steps use Nginx syntax. Certbot also has an Apache plugin, python3-certbot-apache, which works the same way.
Step 5: Add Free SSL to Every Domain with Certbot

Install Certbot with the Nginx plugin:
sudo apt install certbot python3-certbot-nginx -y
Then run Certbot once for each site:
sudo certbot --nginx -d site1.com -d www.site1.com
Certbot asks for an email address. It may also ask whether to redirect HTTP to HTTPS. Say yes. Certbot edits your server block and reloads Nginx.
You could bundle all domains into a single certificate. Skip that shortcut. One failed validation blocks renewal for every name on the certificate. Also, the certificate publicly lists all those names.
Next, test automatic renewal:
sudo certbot renew --dry-run
systemctl list-timers | grep certbot
The dry run proves renewal works. The timer shows when Certbot runs next.
If Certbot fails, check these three causes:
- The domain’s DNS doesn’t point to your VPS yet.
- A firewall or your provider blocks port
80. - The
server_nameline contains a typo.
Step 6: Isolate Each Site with Its Own PHP-FPM Pool and Database
On a shared server, one hacked plugin can expose its neighbors. Separate pools and databases stop that spread. Start with the PHP-FPM pool.
Create the file /etc/php/8.3/fpm/pool.d/site1.conf:
[site1]
user = site1
group = site1
listen = /run/php/site1.sock
listen.owner = www-data
listen.group = www-data
pm = ondemand
pm.max_children = 5
pm.process_idle_timeout = 20s
Each line has a job:
- user and group make PHP run as the site user.
- listen gives the site its own socket.
- listen. owner and listen. group let Nginx connect to that socket.
pm = ondemandstarts workers only when visitors arrive, which saves RAM on idle sites.pm.max_childrencaps how many workers one site can spawn.
Now point the site’s server block at the new socket. Change the fastcgi_pass line to:
fastcgi_pass unix:/run/php/site1.sock;
Then test and restart both services:
sudo php-fpm8.3 -t
sudo systemctl restart php8.3-fpm
sudo nginx -t && sudo systemctl reload nginx
Next, give each site its own database. Install MariaDB and lock it down:
sudo apt install mariadb-server -y
sudo mysql_secure_installation

Open the MariaDB shell with sudo mysql and run these commands:
CREATE DATABASE site1_wp CHARACTER SET utf8mb4;
CREATE USER 'site1_user'@'localhost' IDENTIFIED BY 'replace-with-a-long-random-password';
GRANT ALL PRIVILEGES ON site1_wp.* TO 'site1_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Each database user sees only its own database. As a result, a breach in one site can’t read another site’s data.
Is it safe to host client sites and your own sites together? With these steps, yes, for most projects. A breach in one site can’t read another site’s files or database.
However, the sites still share CPU, RAM, and the IP address. Keep every app updated. Give clients with strict security needs their own VPS.
Step 7: Add WordPress and Other Apps Next to Your Static Sites
Each server block works independently. Therefore, a static site, a PHP app, and a WordPress site can share one VPS. Here is how to install WordPress for site1.com:
cd /tmp
curl -O https://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz
sudo rm /var/www/site1.com/public_html/index.html
sudo cp -a wordpress/. /var/www/site1.com/public_html/
sudo chown -R site1:www-data /var/www/site1.com
sudo find /var/www/site1.com -type d -exec chmod 750 {} \;
sudo find /var/www/site1.com -type f -exec chmod 640 {} \;
Open the domain in your browser. Enter the database name, user, and password from Step 6. Use localhost as the database host. WordPress finishes the install from there.
Pretty permalinks need one change. In the WordPress site’s server block, replace the location / rule:
location / {
try_files $uri $uri/ /index.php?$args;
}
Leave your static sites on the original =404 rule. Each block stays independent.
Caching keeps one busy site from slowing the rest. Use a WordPress caching plugin, or set up Nginx FastCGI caching. Give each site its own cache name and folder. Also skip the cache for logged-in users and the admin area.
Do you run a Node app too? Replace the PHP rules with a proxy_pass http://127.0.0.1:3000; line. Run the app under a process manager. This guide stops there.
Test Every Site and Fix Common Errors
Run this checklist for each domain:
- Run
curl -I https://site1.com. Expect a200or a301to the right address. - Check the certificate with
curl -vI https://site1.com 2>&1 | grep -E "subject|expire". - Open the site in a browser. Confirm the content belongs to that domain.
- Visit the
http://address. Confirm it redirects to HTTPS.
When something breaks, match the symptom to this table:
| Symptom | Likely cause | Fix |
|---|---|---|
| Wrong site loads | Typo in server_name, or the default block is still active | Run sudo nginx -T and search for server_name. Remove the default link. |
502 Bad Gateway | PHP-FPM stopped, or the socket path is wrong | Run sudo systemctl status php8.3-fpm. Compare the path in fastcgi_pass. |
403 Forbidden | Missing index file, or wrong ownership | Confirm the file exists and the group is www-data. |
| Certbot fails | DNS doesn’t point to the VPS yet, or port 80 is blocked | Recheck with dig. Review your UFW rules. |
| Mixed content warnings | Site URLs still start with http:// | Change the WordPress Site Address and Home URL to https://. |
Per-site logs speed up diagnosis. Watch one site’s errors live with this command:
sudo tail -f /var/log/nginx/site1.com.error.log
You can also roll back a single site without touching the others. Remove its link and reload:
sudo rm /etc/nginx/sites-enabled/site1.com
sudo nginx -t && sudo systemctl reload nginx
Keep a Multi-Site VPS Secure and Healthy
A live server attracts bots within hours. Lock down SSH first. Edit /etc/ssh/sshd_config and set these two lines:
PermitRootLogin no
PasswordAuthentication no
Keep a second SSH session open, and test your key login before you close it. Then restart the service:
sudo systemctl restart ssh
Next, add Fail2Ban and automatic security updates:
sudo apt install fail2ban unattended-upgrades -y
Fail2Ban bans IPs that repeatedly fail logins. Unattended upgrades install security patches without your input.
Back up each site on its own. This example saves one database and one folder:
mkdir -p ~/backups
sudo mysqldump site1_wp > ~/backups/site1_wp.sql
sudo tar -czf ~/backups/site1.com.tar.gz /var/www/site1.com
Then copy those files off the server. A provider snapshot restores the whole machine. File-level backups restore a single client site.
Monitor the server too. Use htop for a live view and free -h for memory. A tool like Netdata adds dashboards.
Watch for these signs that you need more resources:
- One site’s traffic slows the others.
- RAM stays nearly full, or swap is in constant use.
- A client needs stronger isolation than shared users give.
- Your domain count climbs toward ten or more.
Prefer a Control Panel? When cPanel or CloudPanel Beats Manual Setup
You don’t need cPanel. The manual setup above works and costs nothing. Still, a panel suits some people better.
cPanel offers a graphical interface for DNS, email, SSL, and backups. It carries a paid license. It also runs only on supported Linux distributions and wants a clean server. Each site gets its own account with separate resource limits.
CloudPanel is free. It adds a Let’s Encrypt certificate for each domain. It also lets you pick a PHP version per site.
Choose a panel if you host many client sites or dislike the terminal. Decide before you configure anything. Panels usually want a clean server.
FAQs
How many websites can one VPS host?
No fixed software limit exists. CPU, RAM, storage, and bandwidth set the ceiling. Measure instead of guessing.
Add sites one at a time. After each, watch free -h and htop during normal traffic. As a rule of thumb, keep 20-25% of RAM free.
Check the average memory of your PHP workers with this command:
ps --no-headers -o rss -C php-fpm8.3 | awk '{sum+=$1} END {print sum/NR/1024 " MB average"}'
Watch for three warning signs:
The load average stays above your vCPU count.
Swap stays in constant use.
Pages slow down at peak hours.
How much RAM do I need to host multiple websites?
Use this table as a starting point:
| Setup | Starting RAM |
|---|---|
| A few static sites and one or two small WordPress sites | 2 GB |
| Three to five WordPress sites with light traffic | 4 GB |
| Six or more WordPress sites, or any busy store | 8 GB, then measure |
These numbers are starting points, not guarantees. Traffic, plugins, and caching change the result.
Each active PHP worker adds memory. A WordPress worker typically uses 40-100 MB. Multiply that by pm.max_children to find the worst case for one site. The database also needs RAM. Swap is a safety net, not a plan.
If one site is blacklisted or hacked, do my other sites suffer?
Step 6 protects files and databases. Separate users and pools keep a breach inside one site. The IP address is a different story.
All your domains share one IP reputation. A hacked site that sends spam can get its IP address blocked. As a result, email from every domain on that IP address may end up in spam folders.
You can cut that risk in three ways:
Keep every app and plugin updated.
Send email through a dedicated email service, not your VPS.
Add a second IP for high-value sites.
To bind a site to a second IP, change its listen line, for example, listen 203.0.113.11:443 ssl;.
Your Next Step After Hosting Multiple Websites on One VPS
Before you add site number two, check one number: how much RAM your VPS has left. Run free -h while your first site handles normal traffic. If you keep a comfortable cushion, add the next site. If not, upgrade the plan first.
Then set up your backup schedule. Do it before the site count grows. A restore plan costs little on one site and a lot on ten.
Ready to put this into practice? Pick a plan with root access and the RAM your site count needs. Choose a Truehost VPS plan.
Web Hosting
Windows HostingBuilt for Windows apps and websites – stability, speed and flexibility
Reseller HostingLaunch a hosting business without technical skills or expensive infrastructure
Affiliate ProgramRefer customers and earn commissions from sales across our platform
Domain SearchFind and secure a domain name in seconds with our quick lookup tool
CO ZA Domains
All DomainsExplore domain names from over 324 TLDs globally – all in one place
Free Whois Lookup Tool South Africa
VPS
SSLs



