LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 01-28-2011, 10:22 AM   #1
gurl4sh25
Member
 
Registered: Apr 2006
Distribution: SuSE, RedHat, Fedora, CentOS, BSD
Posts: 115

Rep: Reputation: 15
Apache question: two website


Hi Guys,

Have a question regarding Apache Webserver. I've been reading some tutorials, and already know how to setup Webservers.

So far have done this scenario

Sample Scenario 1: Simple Webserver (IP 10.0.0.2
- install apache packages
- create index.html file on directory /var/www/html/
- run apache by typing service httpd restart
- testing ok, using command links 10.0.0.2 or links localhost or browsing http://localhost


Sample Scenario 2: One IP Address and two domain servers (www.domain1.com and www.domain2.com)

- edit file /etc/httpd/comf/httpd.conf then add entries below

NameVirtualHost 10.0.0.2

<VirtualHost www.domain1.com>
ServerAdmin admin@domain1.com
DocumentRoot /var/www/html/domain1.com
ServerName www.domain1.com
Error log/domain1.com-error.log
CustomLog logs/domain1.com-access_log common
</VirtualHost>

<VirtualHost www.domain2.com>
ServerAdmin admin@domain2.com
DocumentRoot /var/www/html/domain2.com
ServerName www.domain2.com
Error log/domain2.com-error.log
CustomLog logs/domain2.com-access_log common
</VirtualHost>


- then create index.html on both domain2.com and domain1.com directorys
- start httpd server
- Testing was ok, by using links command on www.domain2.com and www.domain1.com


Now my main question is that, when I've done the said 2 scenario on one server. I can browse www.domain2.com and www.domain1.com, but when I try browsing from a remote computer http://10.0.0.2 or http://localhost. it points to the index.html file on www.domain1.com?

My thinking, when I browse from a remote server it should be like this

1. http://10.0.0.2 ---> output display should be on /var/www/html/index.html (does not work instead it points to the directory /var/www/html/domain1.com/index.html????)
2. http://www.domain1.com --> output display will be on /var/www/html/domain1.com/index.html (no problem)
3. http>//www.domain2.com --> output display will be on /var/www/html/domain2.com/index.html (no problem)

Please help.. I'm a bit confused with this...

Regards,
Gudl4sh25

Last edited by gurl4sh25; 01-28-2011 at 10:49 AM.
 
Old 01-28-2011, 11:18 AM   #2
z1p
Member
 
Registered: Jan 2011
Location: the right coast of the US
Distribution: Ubuntu 10.04
Posts: 80

Rep: Reputation: 23
The apache docs at http://httpd.apache.org/docs/2.0/vhosts/name-based.html covers it quite nicely.


Quote:
Main host goes away

If you are adding virtual hosts to an existing web server, you must also create a <VirtualHost> block for the existing host. The ServerName and DocumentRoot included in this virtual host should be the same as the global ServerName and DocumentRoot. List this virtual host first in the configuration file so that it will act as the default host.
 
1 members found this post helpful.
Old 01-28-2011, 11:46 AM   #3
gurl4sh25
Member
 
Registered: Apr 2006
Distribution: SuSE, RedHat, Fedora, CentOS, BSD
Posts: 115

Original Poster
Rep: Reputation: 15
Hey z1p, thanks a lot. Now I know, Should have read the official document =)

Cheers! =)
 
  


Reply


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
Apache website access rewards Linux - Newbie 7 12-27-2010 08:08 PM
Apache Website not working rossie Linux - Newbie 2 01-22-2010 02:55 PM
Website testing with Apache BinaryLinux Linux - Software 5 08-19-2004 05:45 PM
Apache (website building) question WorldBuilder Linux - Software 2 09-15-2003 09:38 PM
apache website question vadertech Linux - Newbie 6 03-28-2003 04:02 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:57 AM.

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