Linux Virtual Host

Virtual Host Linux

Throughout this document, we attempt to answer the most frequently asked questions about setting up virtual hosts. Apache's virtual hosts make this possible, an important concept that all Linux system administrators should master before using web servers. Edit the following file for Mac and Linux computers. Virtual host refers to the practice of managing multiple servers on a machine, where each server is defined by its hostname (domain). Where are the web server configuration files for the domain located?

To configure virtual Apache hosts on Ubuntu 14.04 LTS

The Apache divides its functions and component into separate entities that can be adapted and configurated separately. This is the term used to describe the base entity that defines an isolated location or a unique top-level domain. Virtual host. This label allows the Admin to use a Web site to host more than one site or site outside a common port or port using a synchronization mechanis.

That' s what you need for anyone who wants to host more than one site outside a VPS. Every preconfigured domaine directs the user to a certain folder with the information of this website, without specifying that the same web site host is also in charge of other websites. You can extend this schema without limitations as long as your servers can cope with the workload.

We' ll take you through setting up virtual Apache host on an Ubuntu 14. 04 VPS. In the course of this proces you will be taught how to provide different contents to different users according to which domain they request. Prior to starting this Tutorial, you should add a non-root users as described in step 1-4.

Apache must also be present to perform these operations. Alternatively, if you have not already done so, you can install Apache on your own machine using apt-get: My setup will create a virtual host for the purpose of this guideline, e.g. com and another for

They are mentioned throughout the guidelines, but you should replace your own domain names or assets as you continue.

This is the top-level folder in which Apache searches for contents to be provided. Our documents roots are placed on separate folders under the /var/wwww folder.

We' ll make a subdirectory here for the two virtual host we want to do. In each of these folders we make a public_html file containing our current data. Sections marked in blue indicate the domains we would like to service from our VPS.

As a result, our normal users now have the public_html sub-directories where we will store our contents. Now your web browser should have the necessary privileges to deliver your contents, and your users should be able to deliver contents to the required directories. Let's make some contents that will work.

You can open an index. html in our editing tool by typing: Within this filename, generate a plain HTML page that indicates which website you are linked to. That'?s what my database looks like: When you are done, store and exit the files. You may copy this data to use as a base for our second website by entering it:

Then we can open the data and change the information: Store and exit this as well. Now you have the necessary pages to test the virtual host setup. The virtual host executables are the executables that determine the true configurations of our virtual host and how the Apache Web servers react to different domains queries.

We' ll copy it to make a virtual host for each of our sites. Let's begin with one of them, set it up, copy it for our second one, and then make the necessary changes.

Ubuntu's standard Ubuntu setup will require that each virtual host executable ends with.conf. Begin by duplicating the filename for the first domain: In your Notepad, open the new document with roots rights: It will look something like this (I have deleted the comment here to make the files more accessible):

The virtual host snippet tunes all queries made on the standard HTTP ports, 80.

ServerAlias is the second name that specifies additional aliases that should coincide as if they were the first name. It is useful to specify the host you want to use, such as www:

All in all, our virtual host should look like this: Store and exit the data set. After creating our first virtual host now, we can build our second by duplicating this and customizing it as needed. In your Notepad, open the new rooted file: you now need to change all the information to point to your second domains.

When you are done, store and exit the data set. The Apache contains some utilities that allow us to do this. Once you are done, you will need to reboot Apache for these changes to take effect: you will most likely get a prompt saying something similar:

At the very least, if you did not use real domain name( that you own) to test this method, and instead used some sample domaines, you can test the capabilities of this method by changing the Host's files on your on-premises computer for a while. It intercepts all queries for the domaines you configure and routes them to your VPS servers, just as the DNS system would if you were using registrated domaines.

Ensure that you are working for these operations on your on-premises computer and not on your VPS servers. When you are on a Mac or Linux computer, modify your locale with administrator rights by entering the following: When you are on a Windows computer, you can find directions for changing your Host files here.

You need to specify the IP addresses of your VPS servers, followed by the name of the VPS you want to use. Under the assumption that my VPS IP adress is for the names I have used in this manual. 111, I could put the following rows at the end of my host file:

As a result, all queries such as com and will be forwarded to our computer and sent to our servers at That' s what we want if we are not actually the owner of these domain names to test our virtual host. Store and exit the data set. Once you have your virtual host set up, you can test your set-up simply by going to the domain (s) you set up in your web browser:

See the image you made for your second website: When these two locations work well, you have successfully set up two virtual host on the same one.

To extend this you can follow the above described procedure to create more virtual host.

Auch interessant

Mehr zum Thema