LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   Apache: View Website (http://www.linuxquestions.org/questions/linux-server-73/apache-view-website-4175443542/)

chief_officer 12-31-2012 01:55 AM

Apache: View Website
 
Hi,

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 100.100.100.100, running a couple of web sites. How can you access site1, site2 via a web browser from a different computer? I have tried http://100.100.100.100/site1, http://100.100.100.100:8080/site1 without any luck.

Seems that I am missing an obvious point.

Thanks for all the assistance.

bijo505 12-31-2012 08:52 AM

Hi,

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

http://www.thegeekstuff.com/2011/07/...-virtual-host/
http://httpd.apache.org/docs/2.2/vhosts/index.html
http://httpd.apache.org/docs/2.2/vhosts/examples.html

--
Thanks,
Bijo

Wim Sturkenboom 12-31-2012 09: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:

127.0.0.1      localhost
100.100.100.100 site1
100.100.100.100 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 04: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 01:07 AM.