bolt Valebyte VPS from $4/mo — NVMe, 60s deploy.

Get a VPS arrow_forward
eco Beginner Tutorial/How-to

Host Multiple Websites on One Dedicated Server with Nginx

calendar_month Jul 30, 2026 schedule 11 min read visibility 11 views
Host Multiple Websites on One Dedicated Server with Nginx
info

Need a server for this guide? We offer dedicated servers and VPS in 50+ countries with instant setup.

Leveraging the power of a dedicated server to host multiple websites is a highly efficient and cost-effective strategy for businesses, developers, and web agencies. With Nginx, a high-performance web server, you can consolidate your web presence onto a single, robust machine, providing unparalleled control and dedicated resources. This comprehensive guide will walk you through setting up multiple websites on your Valebyte dedicated server using Nginx server blocks, ensuring optimal performance and streamlined management.

Need a server for this guide?

Deploy a VPS or dedicated server in minutes.

Why Host Multiple Websites on a Dedicated Server?

Opting for a dedicated server from Valebyte to host multiple websites offers significant advantages over shared hosting or even some cloud environments. You gain:

  • Unmatched Performance: Your websites share dedicated CPU, RAM, and storage resources, ensuring consistent speed and responsiveness, even under heavy traffic. No noisy neighbors impacting your performance.
  • Complete Control: Full root access allows you to customize every aspect of your server environment, from the operating system to specific Nginx configurations, perfectly tailored to your applications' needs.
  • Enhanced Security: With a dedicated server, you are in charge of your security protocols. You can implement advanced firewalls, intrusion detection systems, and custom security measures without interference from other users.
  • Cost-Efficiency: For a growing portfolio of websites or applications, consolidating onto one powerful dedicated server can be more economical than managing multiple smaller hosting plans.
  • Scalability: While sharing a server, you still have the full capacity of your dedicated machine. As your sites grow, you have ample headroom before needing to consider additional hardware.
  • Centralized Management: Streamline updates, backups, and monitoring for all your hosted sites from a single point of access, simplifying your sysadmin tasks.

Prerequisites and Server Requirements

Before diving into the Nginx configuration, ensure you have the following:

1. A Dedicated Server from Valebyte

You'll need a powerful and reliable dedicated server. Our dedicated server offerings provide the raw horsepower and stability required to run multiple Nginx instances efficiently. Ensure your server has sufficient CPU cores, RAM, and disk space to accommodate your anticipated website traffic and data.

2. Operating System

This tutorial focuses on Linux-based operating systems, specifically Ubuntu (20.04 LTS or newer) or Debian. The commands may vary slightly for CentOS/RHEL, but the Nginx configuration principles remain the same.

3. Registered Domain Names

You must have at least two domain names (e.g., website1.com and website2.com) registered and their DNS 'A' records pointing to your dedicated server's public IP address. DNS propagation can take a few hours, so ensure this is done in advance.

4. Root Access via SSH

You'll need SSH access to your dedicated server with a user account that has sudo privileges (or direct root access, though using a sudo user is generally recommended for security).

ssh your_user@your_server_ip

5. Basic Linux Command Line Knowledge

Familiarity with basic Linux commands (e.g., cd, mkdir, ls, nano or vim) will be beneficial.

Step-by-Step Guide: Setting Up Multiple Websites with Nginx

Follow these steps to configure Nginx for multiple websites on your Valebyte dedicated server.

Step 1: Update Your System and Install Nginx

First, ensure your server's package list is updated and all existing packages are upgraded to their latest versions. Then, install Nginx.

sudo apt update
sudo apt upgrade -y
sudo apt install nginx -y

Once installed, Nginx should start automatically. You can verify its status and enable it to start on boot:

sudo systemctl start nginx
sudo systemctl enable nginx
sudo systemctl status nginx

If you have a firewall enabled (like UFW on Ubuntu), you'll need to allow Nginx traffic. Check available Nginx profiles:

sudo ufw app list

You'll likely see 'Nginx HTTP' (port 80), 'Nginx HTTPS' (port 443), and 'Nginx Full' (both 80 and 443). Allow the necessary profiles:

sudo ufw allow 'Nginx HTTP'
# If you plan to use SSL/HTTPS immediately, also allow:
sudo ufw allow 'Nginx HTTPS'
sudo ufw enable # Only if UFW is not already enabled
sudo ufw status

Step 2: Create Directory Structures for Each Website

Each website needs its own root directory where its files will reside. A common practice is to create these under /var/www/.

For website1.com:

sudo mkdir -p /var/www/website1.com/html

For website2.com:

sudo mkdir -p /var/www/website2.com/html

You can repeat this for as many websites as you plan to host. Next, assign ownership of these directories to your non-root user and set appropriate permissions to allow Nginx to read the files.

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

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

To test, create a simple index.html file in each site's html directory:

echo '<h1>Welcome to Website 1!</h1>' | sudo tee /var/www/website1.com/html/index.html
echo '<h1>Welcome to Website 2!</h1>' | sudo tee /var/www/website2.com/html/index.html

Step 3: Create Nginx Server Blocks (Virtual Hosts)

Nginx uses 'server blocks' (analogous to Apache's virtual hosts) to define configurations for individual websites. These files are typically stored in /etc/nginx/sites-available/ and then symlinked to /etc/nginx/sites-enabled/ to activate them.

Create a server block for website1.com:

sudo nano /etc/nginx/sites-available/website1.com

Add the following configuration:

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

    root /var/www/website1.com/html;
    index index.html index.htm index.nginx-debian.html;

    server_name website1.com www.website1.com;

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

    error_page 404 /404.html;
    location = /404.html {
        internal;
    }

    # Optional: Nginx logging for this site
    access_log /var/log/nginx/website1.com_access.log;
    error_log /var/log/nginx/website1.com_error.log;
}

Create a server block for website2.com:

sudo nano /etc/nginx/sites-available/website2.com

Add a similar configuration, adjusting the root and server_name directives:

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

    root /var/www/website2.com/html;
    index index.html index.htm index.nginx-debian.html;

    server_name website2.com www.website2.com;

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

    error_page 404 /404.html;
    location = /404.html {
        internal;
    }

    # Optional: Nginx logging for this site
    access_log /var/log/nginx/website2.com_access.log;
    error_log /var/log/nginx/website2.com_error.log;
}

Understanding Nginx Server Block Directives:

Directive Description Example
listen Specifies the IP address and port Nginx should listen on. 80 is for HTTP, [::]:80 for IPv6 HTTP. listen 80;
root Defines the document root for the requests, where Nginx will look for files. root /var/www/website1.com/html;
index Specifies the default files Nginx should look for when a directory is requested. index index.html index.htm;
server_name Defines which domain names this server block should respond to. Essential for virtual hosting. server_name website1.com www.website1.com;
location / {} A block that processes requests for specific URIs. The / block handles all requests. location / { try_files $uri $uri/ =404; }
try_files Checks for the existence of files in the specified order and serves the first one found. If none are found, it performs an internal redirect to the last argument. try_files $uri $uri/ =404;
access_log Specifies the path for the access log file for this server block. access_log /var/log/nginx/site_access.log;
error_log Specifies the path for the error log file for this server block. error_log /var/log/nginx/site_error.log;

Step 4: Enable Server Blocks

To enable your new server blocks, create symbolic links from sites-available to sites-enabled. Also, remove the default Nginx configuration file to avoid conflicts.

sudo ln -s /etc/nginx/sites-available/website1.com /etc/nginx/sites-enabled/
sudo ln -s /etc/nginx/sites-available/website2.com /etc/nginx/sites-enabled/

sudo rm /etc/nginx/sites-enabled/default

Step 5: Test Nginx Configuration and Restart

Before restarting Nginx, always test your configuration for syntax errors. This prevents downtime due to misconfigurations.

sudo nginx -t

If the test is successful, you should see messages like: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok and nginx: configuration file /etc/nginx/nginx.conf test is successful.

Now, restart Nginx to apply the changes:

sudo systemctl restart nginx

Step 6: Configure DNS Records

Ensure that the 'A' records for website1.com, www.website1.com, website2.com, and www.website2.com (and any other domains) are correctly pointing to the public IP address of your Valebyte dedicated server. You manage these records through your domain registrar or DNS provider. DNS changes can take up to 24-48 hours to fully propagate globally, though it's often much faster.

Step 7: (Optional) Secure with SSL/TLS (Let's Encrypt)

For modern web security and SEO, using HTTPS is crucial. Let's Encrypt provides free SSL/TLS certificates, and Certbot automates the process with Nginx.

Install Certbot and the Nginx plugin:

sudo apt install certbot python3-certbot-nginx -y

Run Certbot for your first domain:

sudo certbot --nginx -d website1.com -d www.website1.com

Follow the prompts. Certbot will automatically modify your Nginx configuration, obtain a certificate, and set up automatic renewal. Repeat this for each domain:

sudo certbot --nginx -d website2.com -d www.website2.com

You can test the automatic renewal process:

sudo certbot renew --dry-run

If you allowed 'Nginx HTTP' only in your firewall previously, remember to allow 'Nginx HTTPS' or 'Nginx Full' now.

rocket_launch Quick pick

Need a dedicated server?

Compare prices from top providers. Configure and order in minutes.

Browse dedicated servers arrow_forward

Practical Use Cases for Multi-Site Hosting on a Dedicated Server

A Valebyte dedicated server configured for multiple websites with Nginx opens up a world of possibilities:

  • Web Agencies & Developers: Host client websites, development environments, staging sites, and personal projects all on one powerful machine. This simplifies management and provides a consistent, high-performance platform.
  • E-commerce Portfolios: Manage multiple online stores for different brands, product lines, or regional variations. Each store benefits from dedicated resources, ensuring fast loading times for shoppers.
  • Content Networks: Run a network of blogs, news sites, forums, or resource portals. This is ideal for SEO strategies that involve interlinked content hubs or managing diverse content streams.
  • Internal Business Applications: Host your company's intranet, project management tools, CRM systems, or other internal web applications, keeping sensitive data within your controlled dedicated environment.
  • Game Server Frontends: While the game servers themselves might run on specific ports, Nginx can host web panels, forums, or landing pages for your various game server instances, all on the same underlying infrastructure.
  • CI/CD Environments: Provide dedicated web interfaces for continuous integration/continuous deployment tools (e.g., Jenkins, GitLab CI dashboards) or host multiple testing environments for different projects.
  • Streaming Services: Host low-latency web frontends for streaming platforms, delivering media assets or managing user interfaces efficiently.
  • Database Management Interfaces: Securely host web-based database administration tools (e.g., phpMyAdmin, Adminer) for multiple databases used by different applications.

Troubleshooting Common Issues

Even with careful planning, issues can arise. Here's how to diagnose and resolve them:

1. Nginx Configuration Test Fails (sudo nginx -t)

  • Symptoms: Error messages indicating syntax errors, unknown directives, or missing files.
  • Solution: Read the error message carefully. It usually points to the exact line number and file where the error occurred. Common mistakes include missing semicolons (;), misspelled directives, incorrect paths, or unclosed braces ({}).
  • Example: nginx: [emerg] unknown directive "rooty" in /etc/nginx/sites-available/website1.com:5 – This indicates a typo in the root directive on line 5.

2. Website Not Loading / Default Nginx Page / 502 Bad Gateway / 403 Forbidden

  • Symptoms: Your browser shows the default Nginx welcome page, a 502 Bad Gateway error, a 403 Forbidden error, or simply fails to load.
  • Solution (Default Page): Check your server_name directive. It must exactly match the domain you are trying to access. Ensure your DNS has fully propagated. If you have multiple server blocks, Nginx might serve the first one in alphabetical order if no specific server_name matches.
  • Solution (502 Bad Gateway): This usually means Nginx couldn't connect to an upstream server (e.g., PHP-FPM). Check if PHP-FPM is running: sudo systemctl status php*-fpm. Check your Nginx error logs for details.
  • Solution (403 Forbidden): This often indicates permission issues. Nginx doesn't have read access to your website's files or directories. Double-check sudo chown and sudo chmod commands for your /var/www/ directories. Also, verify the root directive in your server block.
  • Solution (Website Fails to Load): Check Nginx error logs (/var/log/nginx/error.log) and specific site error logs (e.g., /var/log/nginx/website1.com_error.log) for clues.

3. SSL Errors / Website Not Loading via HTTPS

  • Symptoms: Browser warns about insecure connection, certificate mismatch, or website doesn't load on HTTPS.
  • Solution: Ensure your firewall allows HTTPS traffic (port 443). Verify that Certbot successfully obtained and configured the certificate for your domain. Check your Nginx server block for the HTTPS configuration (usually added by Certbot). Ensure your domain's DNS 'A' record is correctly pointing to your server.

4. Changes Not Taking Effect

  • Symptoms: You've made changes to a server block, but the website behaves as before.
  • Solution: Did you run sudo nginx -t and sudo systemctl restart nginx after making changes? Nginx needs to be reloaded or restarted to pick up new configurations.

5. High Resource Usage on One Site Affects Others

  • Symptoms: One website experiences a traffic spike, and all other sites on the server slow down.
  • Solution: This is a limitation of hosting multiple sites on a single server. Monitor your server's resources (CPU, RAM, Disk I/O) using tools like htop, top, free -h, iostat. Optimize the high-traffic site (caching, code optimization, database optimization). If persistent, consider upgrading your Valebyte dedicated server or migrating the problematic site to its own dedicated instance.

Best Practices for Dedicated Server Multi-Site Management

To maintain a robust and efficient multi-site environment on your Valebyte dedicated server, consider these best practices:

  • Resource Monitoring: Regularly monitor your server's CPU, RAM, disk I/O, and network usage. Tools like Netdata, Grafana with Prometheus, or simple command-line utilities like htop and free -h can provide valuable insights. This helps you anticipate bottlenecks and scale your Valebyte dedicated server resources proactively.
  • Regular Backups: Implement a robust backup strategy for all your websites and server configurations. This should include both file system backups and database dumps, stored securely off-site. Your Valebyte dedicated server provides the ideal environment for setting up custom backup solutions.
  • Security Updates: Keep your operating system, Nginx, PHP-FPM, and any other server software up to date. Regular security patches are crucial for protecting all your hosted websites from vulnerabilities.
  • Detailed Logging: Configure Nginx access and error logs for each website. Regularly review these logs to identify performance issues, security threats, or application errors. This is vital for debugging and maintaining site health.
  • Centralized Management Tools (Optional): For a large number of sites, consider using a web hosting control panel like cPanel or Plesk. While this tutorial focuses on manual Nginx setup, these panels can automate many tasks, including server block creation, SSL management, and user provisioning. However, they add overhead and reduce direct control.
  • Dedicated IP Addresses: While Nginx's Server Name Indication (SNI) allows multiple SSL certificates on a single IP, there might be specific scenarios where a dedicated IP per site is beneficial (e.g., certain legacy systems, specific legal requirements, or email services tied to a domain's IP reputation). Valebyte can provide additional IP addresses if needed.
  • PHP-FPM Pools for Isolation: If you're hosting PHP applications, configure separate PHP-FPM pools for each website. This provides better resource isolation and allows you to run different PHP versions or configurations for different sites without conflict.
  • Version Control: Use Git or another version control system for your website code and even your Nginx configuration files. This helps track changes, collaborate, and revert to previous versions if needed.

check_circle Conclusion

Harnessing the full potential of your Valebyte dedicated server to host multiple websites with Nginx is a powerful and flexible solution. By following this tutorial, you've established a robust foundation for managing diverse web presences with unparalleled performance and control. From e-commerce platforms to development environments and game server frontends, your dedicated server is now equipped to handle a wide array of web applications. For ultimate performance, security, and customization, choose a dedicated server from Valebyte and unlock the true power of your online infrastructure.

help Frequently Asked Questions

Was this guide helpful?

Your feedback helps us improve our guides.

Share this post:

Send this guide to someone who may find it useful.

Telegram VKVK WhatsApp Facebook LinkedIn XX

Nginx multiple websites dedicated server hosting host multiple domains Nginx Nginx server blocks virtual hosts Nginx Valebyte dedicated server bare-metal hosting Nginx web hosting infrastructure configure Nginx for multiple sites sysadmin Nginx tutorial
support_agent
Valebyte Support
Usually replies within minutes
Hi there!
Send us a message and we'll reply as soon as possible.