Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 12-31-2012, 12:55 AM   #1
Registered: Mar 2006
Location: Istanbul, TR
Distribution: Red Hat, CentOS, Ubuntu
Posts: 180

Rep: Reputation: 30
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.
Old 12-31-2012, 07:52 AM   #2
Registered: Nov 2012
Location: Bangalore
Distribution: Fedora & Ubuntu
Posts: 77

Rep: Reputation: 18

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

Old 12-31-2012, 08:10 AM   #3
Wim Sturkenboom
Senior Member
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
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.
Old 01-02-2013, 03:27 AM   #4
Registered: Mar 2006
Location: Istanbul, TR
Distribution: Red Hat, CentOS, Ubuntu
Posts: 180

Original Poster
Rep: Reputation: 30
@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.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Question about setting up to view one website through another mrotsliah Linux - Networking 2 03-16-2010 06:22 PM
How to wget a random file from a website, then use FEH to view it. xmrkite Linux - Software 3 10-17-2006 01:26 PM
View Website Problem? TimmyWa Linux - Networking 1 02-25-2005 03:05 PM
View Website Problem? TimmyWa Red Hat 1 02-25-2005 02:14 PM
Can't View Website Through Windows (Apache 2.0, RH 9.0) TastyWheat Linux - Networking 5 08-22-2003 12:10 PM > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:36 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration