Support article
How to Host Multiple Websites on a VPS
Host multiple websites on a VPS: with a control panel or with Nginx/Apache virtual hosts. Domains, SSL and shared server resources.
Introduction
One of the great advantages of a VPS over shared hosting is that you can host several websites on the same server, without paying extra for each domain. Each website with its own domain, its own SSL and its own configuration.
In this article you’ll see two ways to do it: with a control panel (the easiest) or by configuring virtual hosts manually (more technical but more flexible).
What you need before starting
To host several websites on a VPS you need:
- A VPS with sufficient resources (minimum 2 GB RAM recommended for several websites).
- The domains you’re going to host, pointing to your VPS IP.
- A web server installed (Apache or Nginx) or a control panel.
Remember that each domain must point to your VPS IP via an A record in DNS. If the domains are at miHosting, you can configure it from the panel.
Method 1: Host several websites with a control panel (recommended)
This is the simplest and most visual way. Once a panel like CyberPanel, aaPanel or cPanel is installed on your VPS, adding domains is a matter of clicks.
With CyberPanel
- Log in to the panel.
- Go to Websites → Create Website.
- Enter the domain, email and PHP package.
- Repeat for each domain you want to host.
- For each one, install SSL from the site section.
[Imagen sugerida: screenshot of CyberPanel with several domains added]
With aaPanel
- Log in to aaPanel.
- Go to Website → Add site.
- Enter the domain, create the database if you need it.
- Repeat for each domain.
With cPanel
- Log in to cPanel.
- Go to Domains → Addon Domains.
- Enter the domain, the folder where it’ll be hosted and the database.
- Repeat for each domain.
Panels automatically manage SSL certificates (with Let’s Encrypt), logs and configurations for each domain. That’s why they’re the most convenient option.
Method 2: Host several websites with virtual hosts manually
If you don’t use a panel and prefer to configure the web server directly, you use virtual hosts (Apache) or server blocks (Nginx).
On Apache
Step 1: Create the folder for each website
mkdir -p /var/www/domain1.com
mkdir -p /var/www/domain2.com
Change the owner:
chown -R www-data:www-data /var/www/domain1.com
chown -R www-data:www-data /var/www/domain2.com
Step 2: Create the virtual host for each domain
nano /etc/apache2/sites-available/domain1.com.conf
<VirtualHost *:80>
ServerName domain1.com
ServerAlias www.domain1.com
DocumentRoot /var/www/domain1.com
ErrorLog ${APACHE_LOG_DIR}/domain1_error.log
CustomLog ${APACHE_LOG_DIR}/domain1_access.log combined
</VirtualHost>
Repeat the process for domain2.com.
Step 3: Enable the sites and restart Apache
a2ensite domain1.com.conf
a2ensite domain2.com.conf
systemctl reload apache2
On Nginx
Step 1: Create the folder for each website
Same as Apache.
Step 2: Create the server block for each domain
nano /etc/nginx/sites-available/domain1.com
server {
listen 80;
server_name domain1.com www.domain1.com;
root /var/www/domain1.com;
index index.html index.php;
location / {
try_files $uri $uri/ =404;
}
}
Repeat for domain2.com.
Step 3: Enable the sites and restart Nginx
ln -s /etc/nginx/sites-available/domain1.com /etc/nginx/sites-enabled/
ln -s /etc/nginx/sites-available/domain2.com /etc/nginx/sites-enabled/
nginx -t
systemctl reload nginx
Configure SSL for each domain
With Let’s Encrypt you can generate free certificates for each domain:
certbot --apache -d domain1.com -d www.domain1.com
certbot --apache -d domain2.com -d www.domain2.com
For Nginx:
certbot --nginx -d domain1.com -d www.domain1.com
certbot --nginx -d domain2.com -d www.domain2.com
Certbot renews certificates automatically.
Resource management with several websites
Hosting several websites on a VPS means sharing the server’s resources among all of them. Keep in mind:
- CPU and RAM are distributed among all websites.
- The disk is shared: control the space each takes.
- The database can be shared or one per website.
- If one website has a traffic spike, it can affect the others.
To isolate websites and prevent one from affecting another, some panels allow limiting resources (CPU, RAM, processes) per domain.
Useful tips
- Use a panel if you have several websites. Managing 5 or 10 domains with manual virtual hosts becomes complicated. A panel simplifies everything.
- Control disk space. Each website adds up. Periodically review available space.
- Separate databases. Create a different database and user for each website for security.
- Configure SSL for each domain. Each domain needs its own certificate.
- Back up each website. Don’t mix backups: one per domain, to be able to restore them independently.
Common problems
One website shows another’s content
Review the DocumentRoot (Apache) or root (Nginx) of the virtual host. If two domains point to the same folder, they’ll show the same thing.
A domain doesn’t load
Check that the domain points to the VPS IP (DNS propagation) and that the virtual host is enabled.
SSL fails on a domain
The domain must be propagated (pointing to the VPS) before generating the certificate. If not, Let’s Encrypt gives an error.
One website affects others’ performance
If one website has a traffic spike, it consumes resources that affect the rest. Limit resources per domain from the panel, or upgrade to a higher VPS plan.
I don’t have space for more websites
Each website takes up disk space. Review what’s taking up space with du -sh /var/www/* and clean up what you don’t need, or expand the VPS disk.
Frequently asked questions
How many websites can I host on a VPS?
There’s no fixed limit. It depends on the VPS resources (CPU, RAM, disk) and each website’s traffic. A 2 GB VPS can host several small websites without problem.
Does each website need its own database?
It’s not mandatory, but highly recommended for security and organization. If one database fails, the other websites keep working.
Can I mix WordPress, PrestaShop and static websites on the same VPS?
Yes. Each website is independent and can use the technology it needs, as long as the web server and PHP are installed.
Can the websites see each other?
If properly configured, no. Each website has its own folder and, optionally, its own user. One website shouldn’t be able to access another’s files.
Do I need a VPS for several websites?
Not necessarily. miHosting’s multi-domain shared hosting lets you host several websites without needing a VPS. A VPS is worth it when you need guaranteed resources or total control.
Several websites, one server
Hosting several websites on a VPS is one of its great advantages: one server, several domains, all under your control. If you have several websites, a control panel manages everything visually. If you prefer total control, virtual hosts give it to you.
If you prefer not to handle the technical configuration, at miHosting we offer managed VPS where we install the panel, add your domains, configure SSL and maintain the server for you. You can also opt for our multi-domain hosting if you don’t yet need a VPS. Open a ticket from your client panel and we’ll advise you.