Hosting multiple websites on a cloud server is an excellent way to save some money, especially if your sites aren’t too resource-intensive. And, if you’re on a cloud server, it’s also much easier to scale resources as needed. 

If you’re managing multiple sites and wish to host them on one server, you can use Virtual Server to do this. It’s a configuration setting that allows your webserver, such as Apache, to load the site from the same server. 

In the following guide, we are going to look at how you can host multiple websites on one server using two methods: the standard configuration method (which requires some technical understanding), and how RunCloud lets you do it. 

Hosting Multiple Websites on One Server by Configuring Apache

Apache lets you configure the virtual host. The conf subdirectory in Apache is what you can use to make configuration changes. 

To log into your Apache HTTP server, just connect to your server using your FTP client, and navigate to the conf subdirectory. It’s generally found in /etc/httpd/conf/httpd.conf.

Before you begin, it’s always wise to create a backup of this file. Once you have that, log into the server using an SSH client (Terminal for macOS or PuTTY for Windows). 

You’ll have to enter your login credentials for the root account for the server. Now that you are in, let’s assume that you want to host two sites on the server, example1.com, and example2.com. 

Before you begin, run the following command to create a root directory for both sites:

mkdir /var/www/html/example1.commkdir /var/www/html/example2.com

Next, you need to create an index.html file for both of these sites. You can do that by using the following command for each of the websites:

nano /var/www/html/example1.com/index.html

Now, add the following text:

<html><title>example1.com</title><h1>Welcome to this basic site</h1><p>This is just to show you how to host multiple sites on one server</p></html>

Do this for both of the sites (swap out the URL in the command for each), and then run the following command for both to change the ownership of their directory:

chown -R www-data:www-data /var/www/html/example1.comchown -R www-data:www-data /var/www/html/example2.com

Now, you’ll need to create the virtual host configuration file on Apache for each of these websites. This is possible by running the following command for each:

nano /etc/apache2/sites-available/example1.com.conf

You’ll also need to add the following code to create the Virtual Host:

<VirtualHost *:80>
ServerAdmin [email protected]
ServerName example1.com
DocumentRoot /var/www/html/example1.com
DirectoryIndex index.htmlErrorLog ${APACHE_LOG_DIR}/example1.com_error.logCustomLog ${APACHE_LOG_DIR}/example1.com_access.log combined
</VirtualHost>

Again, you’ll need to do this for both of your sites by swapping out the URLs and replacing them with the sites you want to host.

Once you’re done, you need to enable Virtual Host with the following command:

a2ensite example1.com
a2ensite example1.com

That’s it! You have now configured Apache to serve both sites from the same server. You can now test them by simply typing the URL for each site in your browser!

How to Host Multiple Websites on One Server Using RunCloud

RunCloud makes it easy for you to gain complete control over your server. Once you have connected RunCloud to your servers, it’s incredibly easy to host multiple websites, and you don’t even need any coding expertise. 

Here’s how to do it. 

1. Log into Your RunCloud Dashboard

The first step is to log into your RunCloud dashboard. When you log in, you’ll see an overview of the servers you’ve connected. Here’s how it looks:

connected servers overview in runcloud dashboard

Now, just click on the server, and you’ll see details about any running web apps, server memory, disk consumption, load, and uptime.

server details in runcloud dashboard

2. Deploy a New Web App

The next step is to deploy a new web app on your server. Simply click on the Deploy New Web App button in your dashboard, as shown below:

delopying a new web app on your server

Now, you’ll be asked to enter the details of the app you want to launch. RunCloud supports one-click installs of WordPress and phpMyAdmin, but you can also install a script, connect a Git repository, or launch an empty web app. 

In this example, we are using WordPress.

3. Map Your Domain 

Now, you’ll have to provide information associated with the web app and map a domain. 

provide information associated with the web app and map a domain

You can choose to set up DNS records manually or use Cloudflare DNS with RunCloud. Simply enter your domain name and move to the next step, where you have to provide the admin details and add an SSL certificate.

choose to set up DNS records manually or use Cloudflare DNS with RunCloud

Once you add that in, RunCloud lets you connect to a database and even choose the web application stack that you prefer. In this instance, we are going with NGINX and Apache2 Hybrid, and PHP 7.4, as shown below:

choose the web application stack that you prefer

Once you’re done, just deploy the web app on your server, and it’ll appear as shown below:

deploy the web app on your server

That’s it! You’ve now successfully hosted multiple websites on the same server! 

After Action Report – Hosting Multiple Websites on One Server is Easy with RunCloud

RunCloud makes it incredibly easy to host multiple websites on the same server, and you don’t even need any coding expertise. 

Let us know what method you use to host multiple websites on one server by commenting below, or join the conversation on Twitter by Tweeting @RunCloud_io)! 💬