Premium Managed WordPress Hosting for Serious Websites @ ₹49

How to Host Multiple Websites on One Server | HostingRaja

How to Host Multiple Websites on One Server

Hosting multiple websites on a single server can be a cost-effective and efficient way to manage different projects or domains without needing separate hosting plans for each one. Whether you’re using shared hosting, VPS, or a dedicated server, you can easily set up additional websites by configuring add-on domains, subdomains, or separate directories.

This guide will show you exactly how to configure Apache or NGINX to host multiple websites, plus best practices for managing domains, databases, and security.

Can You Host Multiple Websites on One Server?

Yes, absolutely. Hosting multiple websites on one server is a common practice for businesses, developers, and digital agencies. Modern web servers like Apache and NGINX are designed specifically to handle multiple domains through virtual hosting configurations.

This approach is ideal for:
  • Small businesses managing multiple brand websites
  • Developers handling client projects
  • Entrepreneurs running blog networks
  • Digital agencies offering hosting services

Benefits of Hosting Multiple Websites on One Server

  • Cost-Efficient: You only need one hosting plan instead of separate accounts for each website, significantly reducing monthly expenses.
  • Centralized Management: All your websites are managed from one server, making updates, backups, and monitoring much simpler.
  • Shared Resources: Server resources (CPU, RAM, bandwidth) are utilized more efficiently when properly configured across multiple sites.
  • Simplified Maintenance: System updates, security patches, and configuration changes can be applied once across all sites.

Before You Start: Choosing Your Hosting Plan

Before setting up multiple websites, ensure your hosting plan supports this configuration:

Hosting Type Key Features Best For Limitations
Shared Hosting
(Addon Domains)
  • Most affordable option
  • All websites share CPU & RAM
Low to medium traffic sites, blogs, small business websites Performance may drop if any website gets high traffic
VPS Hosting
(Virtual Private Server)
  • Dedicated resources per website
  • Root access for full control
  • More flexibility
Medium traffic sites, e-commerce websites, growing businesses More expensive than shared hosting
Dedicated Hosting
  • Complete server control
  • Maximum resources & performance
High-traffic websites, large-scale operations, enterprise applications High cost and requires server management
What You’ll Need
  • A hosting plan that supports multiple domains
  • Root or sudo access to your server (for VPS/Dedicated)
  • Domain names purchased and ready to configure
  • Basic command line knowledge

Important: Not every shared hosting plan allows multiple websites. Verify your plan’s capabilities before proceeding, or consider upgrading if needed.

Method 1: Apache Virtual Hosts Setup

Apache’s Virtual Hosts feature allows you to host multiple websites on a single server. Each website gets its own configuration file and document root.

  1. Step 1: Install Apache
  2. First, ensure Apache is installed and running on your server:

    sudo apt update
    sudo apt install apache2
    sudo systemctl start apache2
    sudo systemctl enable apache2

  3. Step 2: Create Directory Structure
  4. Create separate directories for each website:

    sudo mkdir -p /var/www/site1.com/public_html
    sudo mkdir -p /var/www/site2.com/public_html

    Set appropriate permissions:

    sudo chown -R $USER:$USER /var/www/site1.com/public_html
    sudo chown -R $USER:$USER /var/www/site2.com/public_html
    sudo chmod -R 755 /var/www

  5. Step 3: Create Test Pages
  6. Add sample index pages to verify the setup:

    
    echo "<h1>Welcome to Site1</h1>" > /var/www/site1.com/public_html/index.html
    echo "<h1>Welcome to Site2</h1>" > /var/www/site2.com/public_html/index.html
    
          

  7. Step 4: Configure Virtual Hosts
  8. Create a configuration file for each website:

    For site1.com:

    sudo nano /etc/apache2/sites-available/site1.com.conf

    Add this configuration:


    ServerAdmin [email protected]
    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

    For site2.com:

    sudo nano /etc/apache2/sites-available/site2.com.conf

    Once installed, start the Apache service:


    ServerAdmin [email protected]
    ServerName site2.com
    ServerAlias www.site2.com
    DocumentRoot /var/www/site2.com/public_html

    ErrorLog ${APACHE_LOG_DIR}/site2.com-error.log
    CustomLog ${APACHE_LOG_DIR}/site2.com-access.log combined

  9. Step 5: Enable Sites and Restart Apache
  10. Enable the virtual hosts:

    sudo a2ensite site1.com.conf
    sudo a2ensite site2.com.conf
    sudo a2dissite 000-default.conf

    Test the configuration and restart:

    sudo apache2ctl configtest
    sudo systemctl restart apache2

    Method 2: NGINX Server Blocks Setup

    NGINX uses server blocks (equivalent to Apache’s Virtual Hosts) to host multiple websites efficiently.

  1. Step 1: Install NGINX
  2. Install NGINX on your server:

    sudo apt update
    sudo apt install nginx
    sudo systemctl start nginx
    sudo systemctl enable nginx

  3. Step 2: Create Directory Structure
  4. Create separate directories for each website:

    sudo mkdir -p /var/www/site1.com/html
    sudo mkdir -p /var/www/site2.com/html

    Set ownership and permissions:

    sudo chown -R $USER:$USER /var/www/site1.com/html
    sudo chown -R $USER:$USER /var/www/site2.com/html
    sudo chmod -R 755 /var/www

  5. Step 3: Create Test Pages
  6. Add sample index pages:

    
    echo "<h1>Welcome to Site1</h1>" > /var/www/site1.com/public_html/index.html
    echo "<h1>Welcome to Site2</h1>" > /var/www/site2.com/public_html/index.html
    
          

  7. Step 4: Configure Server Blocks
  8. Create configuration files for each website.

    For site1.com:

    sudo nano /etc/nginx/sites-available/site1.com
    server {
    listen 80;
    listen [::]:80;

    server_name site1.com www.site1.com;
    root /var/www/site1.com/html;
    index index.html index.htm;

    location / {
    try_files $uri $uri/ =404;
    }

    access_log /var/log/nginx/site1.com-access.log;
    error_log /var/log/nginx/site1.com-error.log;
    }

    For site2.com:

    To enable the newly created virtual hosts, run:

    server {
    listen 80;
    listen [::]:80;

    server_name site2.com www.site2.com;
    root /var/www/site2.com/html;
    index index.html index.htm;

    location / {
    try_files $uri $uri/ =404;
    }

    access_log /var/log/nginx/site2.com-access.log;
    error_log /var/log/nginx/site2.com-error.log;
    }

  9. Step 5: Enable Sites and Restart NGINX
  10. Create symbolic links to enable the sites:

    sudo ln -s /etc/nginx/sites-available/site1.com /etc/nginx/sites-enabled/
    sudo ln -s /etc/nginx/sites-available/site2.com /etc/nginx/sites-enabled/

    Test configuration and restart:

    sudo nginx -t
    sudo systemctl restart nginx

Post-Setup: DNS, Databases, and Security

Follow the steps below to connect your domain to your server using DNS records.


  1. Log in to your domain registrar
    Example: GoDaddy, Namecheap, Google Domains
  2. Open DNS Management
    Find DNS / Zone Editor for your domain
  3. Create or Update the A Record

    Host @ (or leave blank)
    Type A
    Value Your Server IP Address
    TTL 3600 (or default)
  4. Optional: Add WWW Subdomain

    Host www
    Type CNAME
    Value @ (or your root domain)
Note: DNS propagation can take 24-48 hours, though it’s often much faster.

Set Up Databases (For CMS like WordPress)

If using WordPress or other database-driven applications, create separate databases for each site:

# Access MySQL
sudo mysql -u root -p

# Create database and user for site1
CREATE DATABASE site1_db;
CREATE USER ‘site1_user’@’localhost’ IDENTIFIED BY ‘strong_password’;
GRANT ALL PRIVILEGES ON site1_db.* TO ‘site1_user’@’localhost’;

# Create database and user for site2
CREATE DATABASE site2_db;
CREATE USER ‘site2_user’@’localhost’ IDENTIFIED BY ‘strong_password’;
GRANT ALL PRIVILEGES ON site2_db.* TO ‘site2_user’@’localhost’;

FLUSH PRIVILEGES;
EXIT;

Install SSL Certificates

Secure each website with SSL certificates using Let’s Encrypt (free):

For Apache:

sudo apt install certbot python3-certbot-apache
sudo certbot –apache -d site1.com -d www.site1.com
sudo certbot –apache -d site2.com -d www.site2.com

For NGINX:

sudo apt install certbot python3-certbot-nginx
sudo certbot –nginx -d site1.com -d www.site1.com
sudo certbot –nginx -d site2.com -d www.site2.com

Certbot will automatically:

  • Obtain SSL certificates
  • Update your server configurations
  • Set up auto-renewal

Monitoring and Optimization

Resource Monitoring

Since all websites share server resources, monitor performance regularly:

Check server resource usage:

# CPU and memory usage
htop

# Disk usage
df -h

# Monitor Apache/NGINX processes

systemctl status apache2
systemctl status nginx

Key metrics to watch:

  • CPU usage (should stay below 80% average)
  • Memory usage (watch for memory leaks)
  • Disk space (ensure adequate space for logs and content)
  • Network bandwidth

Performance Optimization Tips

  1. Enable caching – Use browser caching and server-side caching (Redis, Memcached)
  2. Optimize images – Compress and serve images in modern formats (WebP)
  3. Use a CDN – Distribute static assets across multiple servers
  4. Implement resource limits – Prevent one site from consuming all resources
  5. Regular maintenance – Keep server software updated and remove unused files
  6. Log rotation – Configure automatic log cleanup to save disk space
When to Upgrade

Consider upgrading your hosting plan if you notice:

  • Consistent high CPU/memory usage (>80%)
  • Slow page load times across sites
  • Frequent server timeouts or errors
  • Inability to handle traffic spikes
  • One high-traffic site affecting others

Conclusion

Hosting multiple websites on a single server is a cost-effective way to manage multiple domains when configured correctly. Both Apache and NGINX support this setup efficiently, with separate configurations ensuring site independence and SSL securing each domain. Ongoing monitoring, proper resource allocation, and security practices are essential to maintain performance. After setup, thoroughly test all sites, enable automated backups, configure resource-usage alerts, apply security measures, and document the configuration for future reference.

  • Profile

    Mahadeva
    Digital Marketer @ HostingRaja

    Is a Digital Marketer and SEO Enthusiast. With a background in content creation and data analytics, His primary objective is to simplify digital strategies for businesses and individuals alike. He focuses on helping brands enhance their online presence and connect with their audiences effectively. When not immersed in marketing trends and enjoys exploring new cuisines and indulging in his passion for photography.