How to Host Multiple Websites on One VPS
Short answerCreate a separate document root for each domain, add one NGINX server block per site, point every domain’s DNS A record to your VPS primary IP, then test and reload NGINX. VPSGrid provides unmanaged hosting — you administer the guest OS, applications, and data inside the VM.
Overview
One VPS can host many websites when each domain has its own files and virtual host configuration. This guide shows the standard pattern with NGINX on a VPSGrid Linux VPS. Install NGINX first if it is not already running.
What you need
- NGINX installed and responding on the VPS
- Two (or more) domain names you control
- Ability to create DNS A records for each domain
- Root or sudo access over SSH
1) Create a document root per website
# Example for two sites
mkdir -p /var/www/site1.example/public
mkdir -p /var/www/site2.example/public
echo '<h1>Site 1 works</h1>' > /var/www/site1.example/public/index.html
echo '<h1>Site 2 works</h1>' > /var/www/site2.example/public/index.html
# Permissions (adjust user if you run PHP-FPM under another account later)
chown -R root:root /var/www/site1.example /var/www/site2.example
chmod -R 755 /var/www/site1.example /var/www/site2.example2) Add one NGINX server block per domain
Ubuntu / Debian often use /etc/nginx/sites-available + sites-enabled. AlmaLinux / Rocky typically use /etc/nginx/conf.d/*.conf.
Ubuntu / Debian example
cat >/etc/nginx/sites-available/site1.example <<'EOF'
server {
listen 80;
server_name site1.example www.site1.example;
root /var/www/site1.example/public;
index index.html;
access_log /var/log/nginx/site1.example.access.log;
error_log /var/log/nginx/site1.example.error.log;
location / { try_files $uri $uri/ =404; }
}
EOF
cat >/etc/nginx/sites-available/site2.example <<'EOF'
server {
listen 80;
server_name site2.example www.site2.example;
root /var/www/site2.example/public;
index index.html;
access_log /var/log/nginx/site2.example.access.log;
error_log /var/log/nginx/site2.example.error.log;
location / { try_files $uri $uri/ =404; }
}
EOF
ln -sf /etc/nginx/sites-available/site1.example /etc/nginx/sites-enabled/
ln -sf /etc/nginx/sites-available/site2.example /etc/nginx/sites-enabled/
# Optional: remove default site if it conflicts
# rm -f /etc/nginx/sites-enabled/defaultAlmaLinux / Rocky example
cat >/etc/nginx/conf.d/site1.example.conf <<'EOF'
server {
listen 80;
server_name site1.example www.site1.example;
root /var/www/site1.example/public;
index index.html;
access_log /var/log/nginx/site1.example.access.log;
error_log /var/log/nginx/site1.example.error.log;
location / { try_files $uri $uri/ =404; }
}
EOF
cat >/etc/nginx/conf.d/site2.example.conf <<'EOF'
server {
listen 80;
server_name site2.example www.site2.example;
root /var/www/site2.example/public;
index index.html;
access_log /var/log/nginx/site2.example.access.log;
error_log /var/log/nginx/site2.example.error.log;
location / { try_files $uri $uri/ =404; }
}
EOF3) Test configuration and reload
nginx -t
systemctl reload nginx4) Point DNS for every domain
For each domain (and www if used), create an A record to your VPS primary IP. Wait for DNS to propagate, then visit each hostname in a browser.
# Quick checks from your laptop
dig +short site1.example A
dig +short site2.example A
curl -H 'Host: site1.example' http://YOUR_PRIMARY_IP
curl -H 'Host: site2.example' http://YOUR_PRIMARY_IP5) Add HTTPS later (recommended)
After HTTP works for each hostname, install certificates (for example with Certbot) per domain. Do not enable HTTPS redirects until certificates exist for that hostname.
Important notes
- Each site needs its own
server_name, document root, and DNS A record. - Resource limits still apply: CPU, RAM, and bandwidth are shared across all sites on the same VPS.
- VPSGrid is unmanaged — you configure virtual hosts, SSL, and application stacks yourself.
- Refer to vpsgrid.net for current plan specs — this article does not publish fixed pricing.
VPSGrid context
VPSGrid sells unmanaged KVM VPS with root access. You are responsible for guest OS configuration, websites, backups inside the VM, and security hardening. VPSGrid manages hypervisor infrastructure, primary IP connectivity, power controls, and billing.
Frequently Asked Questions
Do I need a separate VPS for each website?
No. One VPS can host many sites if you configure separate virtual hosts and DNS correctly. Heavy traffic sites may still need their own VPS for performance isolation.
Why do both domains show the same default page?
Usually the default server block is catching requests, DNS is wrong, or server_name does not match the hostname you typed. Confirm nginx -t, enabled site files, and DNS A records.
Does this work with Apache instead of NGINX?
Yes in principle (Apache VirtualHosts), but the file paths and commands differ. This article focuses on NGINX. Use the Apache install guides for AlmaLinux/Rocky or Ubuntu first, then create one VirtualHost per domain.
What if I am stuck after following this guide?
Open a ticket with your service ID, primary IP, OS version, domain names, and the output of nginx -t.
Related Articles
Need More Help?
Search this knowledge base for related guides. For billing, provisioning, or primary IP assignment issues, open a ticket at billing.vpsgrid.net with your service ID, primary IP, and steps already tried.
¿Le ha resultado útil esta respuesta?