LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 05-10-2004, 01:07 PM   #1
tictocdoc
LQ Newbie
 
Registered: Sep 2003
Location: Houston,TX
Distribution: RedHat/SuSe/Mandrake
Posts: 20

Rep: Reputation: 0
Virtual Host Problem


Hello:

I am experiencing a problem getting my virtual hosts to work properly. I am using Mandrake 10 / Apache 2X. I have several websites that I am trying to set up as Name Based and IP Based virtual hosts. No matter what I do, only the first virtual host listed in the Vhosts.conf file is the only one that comes up when I try to access my server. If I remark out the first host, then the next one in the list takes over. I am sure that this is a simple problem but it's got me stumped. Any help/ideas would be greatly appreciated.

Thanks,

Michael
 
Old 05-10-2004, 01:22 PM   #2
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
Post the part of the configuration that governs the virtual hosts and I might be able to help you out.
 
Old 05-10-2004, 01:50 PM   #3
tictocdoc
LQ Newbie
 
Registered: Sep 2003
Location: Houston,TX
Distribution: RedHat/SuSe/Mandrake
Posts: 20

Original Poster
Rep: Reputation: 0
Here is what is in my Vhosts.conf file currently:

################# IP-based Virtual Hosts
<VirtualHost 192.168.X.XX>
DocumentRoot /var/www/html/website 1
ServerName XXX.com
RewriteEngine On
RewriteOptions inherit
</VirtualHost>

################# Named VirtualHosts
NameVirtualHost 192.168.X.XX
<VirtualHost 192.168.X.XX>
ServerName www.website 2.com
RewriteEngine On
RewriteOptions inherit
ServerAdmin owners@website 2.com
ServerPath /website2
DocumentRoot /var/www/html/website2
</VirtualHost>

################# Named VirtualHosts
NameVirtualHost 192.168.X.XX
<VirtualHost 192.168.X.XX>
ServerName www.website3.net
ServerAdmin webmaster@website3.net
RewriteEngine On
RewriteOptions inherit
ServerPath /website3
DocumentRoot /var/www/html/website3
</VirtualHost>

################# Named VirtualHosts
NameVirtualHost localhost
<VirtualHost localhost>
ServerName www.website4.org
ServerAdmin webmaster@website4.org
RewriteEngine On
RewriteOptions inherit
ServerPath /website4
DocumentRoot /var/www/html/website4
ServerSignature Off
</VirtualHost>

################# Named VirtualHosts
NameVirtualHost localhost
<VirtualHost localhost>
ServerName www.website5.org
ServerAdmin gatekeeper@website5.org
RewriteEngine On
RewriteOptions inherit
ServerPath /paganways
DocumentRoot /var/www/html/website5
ServerSignature Off
</VirtualHost>

Thanks in advance for the help!!!!

Michael
 
Old 05-10-2004, 02:30 PM   #4
adm1329
Member
 
Registered: Mar 2004
Distribution: CentOS 5
Posts: 128

Rep: Reputation: 17
here's what the virtual host section of my httpd.conf file looks like edited to remove real IP's etc...

Code:
# Virtual host site1
<VirtualHost 192.168.0.1>
        DocumentRoot /var/www/html
        ServerAdmin postmaster@site1.com
        ServerName www.site1.com
        DirectoryIndex index.php index.html index.htm index.shtml
        LogLevel debug
        HostNameLookups off
</VirtualHost>

# Virtual host Virtual Host 0
<VirtualHost 192.168.0.1>
        DocumentRoot /var/www/site2/html/
        ServerAdmin postmaster@site2.com
        ServerName www.site2.com
        DirectoryIndex login.php index.php
</VirtualHost>

# Virtual host site3
<VirtualHost 192.168.0.2>
        DocumentRoot /var/www/site3/html
        ServerAdmin postmaster@site3.com
        ServerName www.site3.com
        DirectoryIndex index.html index.php index.htm index.shtml
</VirtualHost>
The only thing I can see is that I don't have the NameVirtualHost in mine and my name based works fine. You said you're trying to set up name based and IP based, but all I see here is name based. You can see an example of IP based in mine, sites 1 and 2 are on one IP and site 3 is on another. So sites 1 and 2 are name based and site 3 is IP based.

Are you trying to pull this up from the local machine or another computer on the lan? Are the domains already in a DNS server to point to the proper IP? If you're trying from the local machine try another computer on the lan, if the domains aren't already in DNS and trying to access from a windows 2k or xp (not sure if it's the same in 9x) edit the lmhosts.sam file and add
www.site1.com 192.168.0.1
www.site2.com 192.168.0.1

And then see if it will pull them properly.
 
Old 05-10-2004, 02:52 PM   #5
tictocdoc
LQ Newbie
 
Registered: Sep 2003
Location: Houston,TX
Distribution: RedHat/SuSe/Mandrake
Posts: 20

Original Poster
Rep: Reputation: 0
Thanks for the reply. I guess that I am still confused as to the difference between IP and Name Based. I have read the Apache docs and thought I understood the difference. From looking at your config file, it looks to me that "Virtual Host Site 1" is your "default" virtual host. Is that correct??? If that is the case, do I need to specify the DirectoryIndex specifications for the rest of the virtual hosts? I had initially tried assigning several virtual IP addresses to my NIC so that I could use IP based virtual hosting (since 2 of these sites are going to be e-commerce sites and I need SSL functionality), but I couldn't get that to work either. I have tried accessing the sites from both the localhost and also another machine on my lan. I get the same results. For example, my primary domain (home) is www.tictocdoc.com, and my "new" domain is www.paranormalreport.org. I currently have "tictocdoc" commented out in my Vhosts.conf file (and stopped and restarted httpd). If you go to it now you will get paranormalreport.org. If you go to paranormalreport.org, you still get the same site. As you can probably tell, paranormalreport.org is a PHP-Nuke site. I will have 2 of these type sites total. The other sites were created in a standard html editor. My ultimate goal is to have 4-5 Name Based virtual hosts and 2 IP/SSL based virtual hosts on the same server with only 1 NIC.

Thanks again for all of your help.

Last edited by tictocdoc; 05-10-2004 at 02:54 PM.
 
Old 05-10-2004, 07:33 PM   #6
adm1329
Member
 
Registered: Mar 2004
Distribution: CentOS 5
Posts: 128

Rep: Reputation: 17
hmm... I don't know about Mandrake, but on Fedora it was easy to accomplish both.

Yes site 1 is my default Virtual Host.

As far as the DirectoryIndex when I set up the virtual hosts with the configuration utility in Fedora it automatically put that there. So it wouldn't be a bad idea to put it there.

The only other thing I see is the ServerPath variable. But that shouldn't be an issue.

try putting the NameVirtualHost inside the <VirtualHost 192.168.x.x></VirtualHost>
 
Old 05-11-2004, 08:12 AM   #7
tictocdoc
LQ Newbie
 
Registered: Sep 2003
Location: Houston,TX
Distribution: RedHat/SuSe/Mandrake
Posts: 20

Original Poster
Rep: Reputation: 0
Hello I tried copying your file (making the appropriate changes for my system). It worked sort of. I restored my original file that I backed up several days ago and all 3 of my sites work as designed. I believe that the problems were caused by the changes that I made to httpd.conf for the addition of 2 new PHP-Nuke based sites. Seems like things started getting stranged after I added those changes. I will do more research on adding PHP sites to MD10 before I add them again.

Thanks for everyone's help!!!!
 
Old 05-12-2004, 09:08 PM   #8
TankerKevo
Member
 
Registered: Sep 2003
Location: Tampa
Distribution: RH9 & FC2
Posts: 55

Rep: Reputation: 15
If you find that when you goto your site (www.yoursite.com) it seems dead try using your full taget page name (www.yoursite.com/index.htm).

If the latter works, add this directive inside each of your virtual hosts:

DirectoryIndex index.php index.html index.htm index.shtml

Last edited by TankerKevo; 05-12-2004 at 09:09 PM.
 
  


Reply



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 Virtual Host Problem eckertc1 Linux - Newbie 11 03-23-2005 03:31 PM
Router Virtual Host Problem E-Oreo Linux - Networking 1 09-15-2004 07:17 AM
Apache virtual host problem Adrohak Linux - Software 3 07-18-2004 04:17 PM
Name Based Virtual Host problem helios007 Linux - Networking 6 12-21-2003 03:41 PM
virtual host problem Michele Linux - Newbie 5 08-18-2003 11:05 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 01:58 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