We earn commission when you buy through affiliate links.

This does not influence our reviews or recommendations.Learn more.

Lets learn how to configure Apache and Nginx to host multiple websites.

Hosting sites on theCloud servergives much flexibility compared toshared hosting.

you might install whatever you like, scale up or down, and configure for better performance and cost-optimization.

Lets take a look at this scenario.

I have the following two sites which I would like to point to my one cloud VM.

Before implementation, lets understand how it works.

The concept to have multiple websites on a single web server instance is calledVirtual Server.

It is defined in the configuration file along with the URL.

Configure Virtual Host in Nginx to host multiple domains

There are multiple ways to achieve this.

Either you’re free to modifynginx.conffile or custom file if you have any.

You may also create acustom.confunder conf.d folder.

Choose what works for you and take a backup if modifying an existing file.

Note:Change the value forroot,server_namebased on your requirement.

Dont forget to update the DNS record of your URL to map to server IP.

That was the quick guide to hosting multiple domains in a single web server instance like Apache or Nginx.

Once your website is live, dont forget totest it against security vulnerabilities.