Step Four - Create New Virtual Host Files You now have the pages necessary to test the virtual host configuration. We can copy this file to use as the basis for our second site by typing: cp /var//var/We can then open the file and modify the relevant pieces of information: nano /var/ Save and close the file when you are finished. We can open up an index.html file in our editor by typing: nano /var/In this file, create a simple HTML document that indicates the site it is connected to. We’re just going to make an index.html page for each site.
We’re just going for a demonstration, so our pages will be very simple. We have our directory structure in place.
Step Three - Create Demo Pages for Each Virtual Host This will allow you to test your configuration from your home computer, even though your content won’t be available through the domain name to other visitors.
We will show how to edit your local hosts file later on to test the configuration if you are using dummy values. If you do not have domains available to play with, you can use dummy values. To learn how to set up your domain names with DigitalOcean, follow this link. These will be referenced throughout the guide, but you should substitute your own domains or values while following along. If you haven’t already done so, you can get Apache installed on your server through apt-get: sudo apt-get updateĪfter these steps are complete, we can get started.įor the purposes of this guide, my configuration will make a virtual host for and another for. You will also need to have Apache installed in order to work through these steps. During this process, you’ll learn how to serve different content to different visitors depending on which domains they are requesting.īefore you begin this tutorial, you should create a non-root user as described in steps 1-4 here. In this guide, we will walk you through how to set up Apache virtual hosts on an Ubuntu 14.04 VPS.
This scheme is expandable without any software limit as long as your server can handle the load. This is relevant to anyone looking to host more than one site off of a single VPS.Įach domain that is configured will direct the visitor to a specific directory holding that site’s information, never indicating that the same server is also responsible for other sites. These designations allow the administrator to use one server to host multiple domains or sites off of a single interface or IP by using a matching mechanism. The basic unit that describes an individual site or domain is called a virtual host. It accounts for more than half of all active websites on the internet and is extremely powerful and flexible.Īpache breaks its functionality and components into individual units that can be customized and configured independently.
The Apache web server is the most popular way of serving web content on the internet.