How to Host a Client Website on Your VPS Without Mixing It with Your Own
When you host a client website on VPS space that also runs your own sites, one wrong permission or one shared database user can mix the two together. A client plugin update can take down your blog. A client upload folder with loose permissions can expose your files. The fix is not a second server. You can host a client website on VPS infrastructure you already pay for, as long as each site gets its own user, its own PHP pool, and its own database. This guide walks through that setup on Ubuntu 24.04 with Nginx and PHP-FPM.
The idea is simple: treat the client site as a tenant. It lives in its own folder, runs as its own user, talks to its own database, and has its own backup. Your sites keep running exactly as before, and nothing the client does can reach them.
Why Keep Client Sites Separate From Your Own
Shared hosting mixes tenants by design, and that is why one hacked site on a shared server can infect its neighbours. A VPS gives you the tools to avoid that, but only if you use them. If the client site runs as the same Linux user as your sites, reads the same files, and shares one MySQL user, you have rebuilt shared hosting on your own server, with all of its risks and none of its support team.
Separation also makes handover clean. When the client moves away, you delete one user, one folder, and one database. You do not have to pick through shared folders wondering which file belongs to whom. And when something breaks, the logs tell you which site broke, because each site has its own pool and its own error log.
There is a cost: a little more setup time per site, and a little more RAM, since each PHP pool keeps its own workers. On a 2 GB VPS that is usually fine for a handful of small sites. If you are unsure how much RAM a site needs, start from our guide to tuning PHP-FPM pm settings for a 2 GB RAM VPS and size each pool to the traffic it actually serves.
How to Host a Client Website on VPS Without Touching Your Own Sites
The setup has four steps: create a Linux user for the client site, create a PHP-FPM pool that runs as that user, create a database and a database user that only that site can use, and point an Nginx server block at the site. The pattern is one separate Linux user per site, one pool per site, and one database per site. Each step is independent, so you can check your work as you go.
Before you start, decide on names. Use the client domain for the folder and user where you can, for example clientdomain.com for the site and clientdomain for the user. Clear names make the next steps easy to follow and the cleanup easy later.
Give the Client Site Its Own Linux User
Create a user with no shell login and no home folder outside the web root. The user exists only to own the site files and run its PHP pool.
sudo useradd -M -s /usr/sbin/nologin clientdomain
sudo mkdir -p /var/www/clientdomain.com/public_html
sudo chown -R clientdomain:clientdomain /var/www/clientdomain.com
sudo chmod 755 /var/www/clientdomain.com
The -M flag skips creating a home folder, and -s /usr/sbin/nologin blocks shell access. The site folder belongs to the new user, and nobody else can write to it. File permissions are the first wall between sites: if the client site is ever compromised, the attacker runs as clientdomain and cannot read your folders, because your folders belong to a different user. Our guide to Linux file permissions for /var/www explains the 755 and 644 pattern this setup relies on.
If the client needs to upload files by SFTP, create a separate SFTP-only account for them instead of handing over your own login. That account should be locked to the client folder and unable to reach the rest of the server. Our guide to creating sudo users and disabling root login covers the user management habits that keep this safe.
Give the Client Site Its Own PHP-FPM Pool
PHP-FPM pools decide which Linux user runs a site’s PHP code. Separate PHP-FPM pools turn folder separation into real isolation: the client site’s PHP processes run as clientdomain, so they can only touch files that user can touch.
Copy the default pool file and edit the copy:
sudo cp /etc/php/8.3/fpm/pool.d/www.conf /etc/php/8.3/fpm/pool.d/clientdomain.conf
sudo nano /etc/php/8.3/fpm/pool.d/clientdomain.conf
Change the pool name and the user, group, and socket lines:
[clientdomain]
user = clientdomain
group = clientdomain
listen = /run/php/php8.3-fpm-clientdomain.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 low for a small client site. Five children is enough for a brochure site or a small shop, and it leaves RAM for your own sites. Then restart PHP-FPM and check the new socket exists:
sudo systemctl restart php8.3-fpm
ls /run/php/ | grep clientdomain
If the service fails to start, the pool file has a typo or a duplicate pool name. Read the error with sudo journalctl -u php8.3-fpm --no-pager -n 30 before changing anything else.
Give the Client Site Its Own Database and User
Never share a MySQL user between sites. Create a database and a user for the client site only, with access to that one database and nothing else.
sudo mysql -e "CREATE DATABASE clientdomain_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
sudo mysql -e "CREATE USER 'clientdomain_user'@'localhost' IDENTIFIED BY 'a-strong-password-here';"
sudo mysql -e "GRANT ALL PRIVILEGES ON clientdomain_db.* TO 'clientdomain_user'@'localhost';"
sudo mysql -e "FLUSH PRIVILEGES;"
Generate a real password with a password manager instead of typing a weak one. The client site’s wp-config.php holds these credentials, and since the file belongs to the client user, your other sites cannot read it. That is the whole point of client website isolation on a VPS: a leaked credential opens one door, not every door on the server.
Point Nginx at the Client Site
Create a server block for the client domain. The only line that ties this block to the client pool is fastcgi_pass, which names the client socket. Everything else is a standard WordPress block.
server {
listen 80;
server_name clientdomain.com www.clientdomain.com;
root /var/www/clientdomain.com/public_html;
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-clientdomain.sock;
}
}
Save it as /etc/nginx/sites-available/clientdomain.com, link it into sites-enabled, test the config, and reload Nginx:
sudo ln -s /etc/nginx/sites-available/clientdomain.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
If you are still learning server blocks, our guide to setting up Nginx server blocks on Ubuntu 24.04 walks through each directive. Once the block is live, install WordPress or upload the site files into public_html as the client user, then finish the WordPress setup with the database and user you created above.
Backups: Keep Client Data on Its Own Schedule
Back up the client site separately from your own. A single backup that mixes all sites makes a restore messy: you cannot restore the client site without touching your own data. Run one backup job per site, with the folder and the database dump in the same archive.
sudo mysqldump clientdomain_db | gzip > /var/backups/clientdomain_db.sql.gz
sudo tar -czf /var/backups/clientdomain_files.tar.gz -C /var/www/clientdomain.com public_html
Put both commands in a small script and run it from cron, then copy the archives off the server. Our guide to automatic MySQL backups with mysqldump and cron shows the cron pattern. Test a restore at least once: a backup you have never restored is a guess, not a backup.
What to Do When the Client Leaves
When a client moves on, removal is four commands: delete the Nginx block and its symlink, delete the PHP pool, drop the database and its user, and delete the site folder and Linux user. Keep the final backup for a month or two in case the client comes back asking for their files, then delete it too.
sudo rm /etc/nginx/sites-enabled/clientdomain.com /etc/nginx/sites-available/clientdomain.com
sudo rm /etc/php/8.3/fpm/pool.d/clientdomain.conf
sudo mysql -e "DROP DATABASE clientdomain_db; DROP USER 'clientdomain_user'@'localhost';"
sudo userdel clientdomain
sudo rm -rf /var/www/clientdomain.com
Reload Nginx and restart PHP-FPM after the cleanup, then check that your own sites still load. That is the test that matters: the client is gone, their files are gone, and your sites never noticed.
Hosting a client site on your own VPS works well when the boundaries are real. One user, one pool, one database, one backup. Set those up before the first page loads, and the client site stays a tenant, not a roommate in your own home.