01When one server is the right choice
Running several low-traffic sites on one VPS (DigitalOcean, Hetzner, AWS Lightsail and similar) is cheaper and simpler than paying for separate hosting for each. It suits brochure sites, small WordPress installs and staging copies.
It is not the right choice when one site is business-critical and the others are not: a traffic spike or a compromised plugin on one site affects everything on the box. In that case, give the important site its own server or container.
02Before you start
- A server running Ubuntu 24.04 LTS, with a non-root user that can use
sudo. - A DNS
Arecord (andAAAAfor IPv6) for each domain pointing at the server's IP address. - The firewall allowing web traffic:
sudo ufw allow 'Nginx Full'.
03Install Nginx and PHP
Install Nginx, and PHP-FPM if any of the sites run PHP (WordPress, Laravel and so on):
sudo apt update
sudo apt install nginx php-fpm php-mysql
systemctl status nginx
Ubuntu 24.04 ships PHP 8.3, so the PHP-FPM socket is /run/php/php8.3-fpm.sock. Check the exact name with ls /run/php/.
04Give each site its own folder and owner
Keep every site in its own directory so files, permissions and backups stay separate:
sudo mkdir -p /var/www/example.co.uk/public
sudo mkdir -p /var/www/second-site.com/public
sudo chown -R $USER:www-data /var/www/example.co.uk /var/www/second-site.com
For sites run by different people, use a separate system user and PHP-FPM pool per site, so one site cannot read another's files.
05Create a server block for each domain
Each site gets a file in /etc/nginx/sites-available/. A minimal PHP site looks like this:
server {
listen 80;
listen [::]:80;
server_name example.co.uk www.example.co.uk;
root /var/www/example.co.uk/public;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
}
location ~ /\.(?!well-known) {
deny all;
}
}
Repeat for the second domain with its own server_name and root. Then enable both, remove the default site, test and reload:
sudo ln -s /etc/nginx/sites-available/example.co.uk /etc/nginx/sites-enabled/
sudo ln -s /etc/nginx/sites-available/second-site.com /etc/nginx/sites-enabled/
sudo rm /etc/nginx/sites-enabled/default
sudo nginx -t && sudo systemctl reload nginx
Nginx picks the server block whose server_name matches the domain in the request, which is how one IP address serves several sites.
06Add free HTTPS with Let’s Encrypt
Certbot requests certificates and updates the server blocks for you:
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d example.co.uk -d www.example.co.uk
sudo certbot --nginx -d second-site.com -d www.second-site.com
Choose the option to redirect HTTP to HTTPS. Certificates renew automatically through a systemd timer; confirm renewal works with sudo certbot renew --dry-run.
07Check it properly
- Visit each domain with and without
www, over HTTP and HTTPS, and confirm you land on the right site. - Request the server by its IP address: it should not show one of your client sites by accident. A small catch-all
default_serverblock returning444prevents that. - Read
/var/log/nginx/error.logafter the first few requests.
08Keep it running
Turn on unattended security updates, back up each site's files and database separately, and monitor disk space, because one site's logs or uploads can fill the disk for all of them. If you would rather not manage this yourself, we set up and look after servers like this for clients.