-   Linux - Server (
-   -   Apache: View Website (

chief_officer 12-31-2012 12:55 AM

Apache: View Website

Wish everyone a happy, prosperous new year.

I have a question about viewing a website on Apache. Suppose you are running a test server on a public IP; say, running a couple of web sites. How can you access site1, site2 via a web browser from a different computer? I have tried, without any luck.

Seems that I am missing an obvious point.

Thanks for all the assistance.

bijo505 12-31-2012 07:52 AM


Kindly have a look at the following URL, that will help you set up the virtual host


Wim Sturkenboom 12-31-2012 08:10 AM

I assume you have not registered your websites. If you have, it should just be a matter of entering http://site1 in your browser's addrss bar and pressing <enter>.

If the websites are not registered:

Setup a couple of lines in /etc/hosts (for linux) on the machine where the browser runs; the location of the hosts file on a windows system is somewhere in a subdirectory (of a subdirectory ...) of the windows directory.

Code:      localhost site1 site2

The first line is a standard entry in the hosts file on every system; add the other two (or more if you have more sites)

Explanation, if needed
When you enter http://site1 in you browser address bar and press <enter>, the first thing the browser does is attempt to translate the hostname (site1) to an ip-address; this is called 'resolving the hostname' and makes use of DNS servers (on the web or in your network) and the hosts file on the client machine. If the hostname can't be resolved, you will get something like 'server not found'. If it can be resolved, it will send a http request to the obtained ip-address. This http request will contain somewhere information about which site you want to visit (site1). Apache sees this when the request comes in and serves the correct page (if apache is configured correctly; read up on name based virtual hosts in the apache documentation of necessary).

By adding the two lines to the hosts file, you make that the name can be resolved and everything should work as expected. This assumes that the host file is part of the resolving which is, to my knowledge, usually the case.

chief_officer 01-02-2013 03:27 AM

@bijo505 I already have the virtual hosts running. Thank you very much for your answer.
@Wim Sturkenboom Thank you very much for your detailed explanation.

All times are GMT -5. The time now is 02:50 AM.