LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 08-24-2004, 01:48 AM   #1
dontaylor2
LQ Newbie
 
Registered: Jan 2004
Location: Pine Bluff, AR
Distribution: Ubuntu
Posts: 15

Rep: Reputation: 0
Virtual Hosting doesn't work, period!


I run RH 8.0 and have tried everything to get name based virtual hosting working. I've read countless HOWTOs, a book on Apache... you name it. Here's the pertinent portions of my (latest) httpd.conf file:

Listen 80

ServerName 1.2.3.4:80

NameVirtualHost *:80

<VirtualHost *:80>
ServerAdmin webmaster@domain1.org
ServerAlias *.domain1.org
DocumentRoot /var/www/html/domain1
ServerName domain1.org
DirectoryIndex index.php index.html
</VirtualHost>

<VirtualHost *:80>
ServerAdmin webmaster@domain2.com
ServerAlias *.domain2.com
DocumentRoot /var/www/html/domain2
ServerName domain2.com
DirectoryIndex index.php index.html
</VirtualHost>

There is no default document set up, and you know the best part? It doesn't seem to matter if I change the order of the virtual hosts. Domain1.org *always* shows up first.
 
Old 08-24-2004, 03:22 AM   #2
pnh73
Member
 
Registered: Jul 2003
Location: Birmingham, UK
Distribution: Ubuntu,Debian
Posts: 381

Rep: Reputation: 30
Hi,

I had this problem when starting out with apache! Its really very frustrating... However, if my memory serves me correctly I have a solution for you. You need to change your configuration to the following:

Code:
Listen 80

#--> I dont know if u need the ServerName Directive or not, it depends on your situation.

NameVirtualHost 1.2.3.4 # --> I have no port number in my configuration

<VirtualHost 1.2.3.4:80> # Add the IP you want it to listen on, rather than *
ServerAdmin webmaster@domain1.org
ServerAlias *.domain1.org
DocumentRoot /var/www/html/domain1
ServerName domain1.org
DirectoryIndex index.php index.html
</VirtualHost>

<VirtualHost 1.2.3.4:80> # Add the IP you want it to listen on, rather than *
ServerAdmin webmaster@domain2.com
ServerAlias *.domain2.com
DocumentRoot /var/www/html/domain2
ServerName domain2.com
DirectoryIndex index.php index.html
</VirtualHost>
I hope that helps you/solves your problem, as that is similar to what I am using, and I am running about 10 virtual hosts.
 
Old 08-24-2004, 11:06 AM   #3
dontaylor2
LQ Newbie
 
Registered: Jan 2004
Location: Pine Bluff, AR
Distribution: Ubuntu
Posts: 15

Original Poster
Rep: Reputation: 0
Didn't work

Thanks for the reply, but that didn't work. Now I get the Apache Test Page for both domains.

I've seriously tried several different variants in using the IP, using the domain name, and using * in the NameVirtualHost directive, as well as using/dropping the port number. I feel like I must have it set up correctly. I'm wondering at this point if there's some strange, undocumented feature that Red Hat imposed on us like they did with sendmail, where it would only accept mail from localhost until you changed it.
 
Old 08-24-2004, 12:47 PM   #4
Pete M
Member
 
Registered: Aug 2003
Location: UK
Distribution: Redhat 9 FC 3 SUSE 9.2 SUSE 9.3 Gentoo 2005.0 Debian Sid
Posts: 657

Rep: Reputation: 30
dontaylor2

Does Apache have permission to access /var/www/html/domain2 ?

By default Apache does'nt have permission to access any directories as below

<Directory />
Order Deny,Allow
Deny from all
</Directory>
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>

So you have to give Apache permission like this

<VirtualHost *:80>
ServerAdmin webmaster@domain2.com
ServerAlias *.domain2.com
DocumentRoot /var/www/html/domain2
ServerName domain2.com
DirectoryIndex index.php index.html
<Directory "/var/www/html/domain2">
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

Hope this helps

Pete
 
Old 08-24-2004, 02:23 PM   #5
dontaylor2
LQ Newbie
 
Registered: Jan 2004
Location: Pine Bluff, AR
Distribution: Ubuntu
Posts: 15

Original Poster
Rep: Reputation: 0
Talking YEAH!!!

OKAY, that's got it! Thank you both VERY much. I've posted my final config below for posterity. I did end up removing the port numbers, but I also replaced the IP with *. I may eventually do some testing to see whether I can get it working with the actual IP too, but for now I'm just going to relax and enjoy the fact that it's working. =)

Thanks again!

- Don

NameVirtualHost *

<VirtualHost *>
ServerAdmin webmaster@domain1.com
ServerAlias *.domain1.com
DocumentRoot /var/www/html/domain1
ServerName domain1.com
DirectoryIndex index.php index.html
<Directory "/var/www/html/domain1">
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost *>
ServerAdmin webmaster@domain2.org
ServerAlias *.domain2.org
DocumentRoot /var/www/html/domain2
ServerName domain2.org
DirectoryIndex index.php index.html
<Directory "/var/www/html/domain2">
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
 
Old 08-24-2004, 02:53 PM   #6
Pete M
Member
 
Registered: Aug 2003
Location: UK
Distribution: Redhat 9 FC 3 SUSE 9.2 SUSE 9.3 Gentoo 2005.0 Debian Sid
Posts: 657

Rep: Reputation: 30
dontaylor2

You have no idea how long it took me to work this out on my own server and to this day I have never seen any documentation referring to it

Glad I could help

Pete
 
Old 08-24-2004, 05:38 PM   #7
pnh73
Member
 
Registered: Jul 2003
Location: Birmingham, UK
Distribution: Ubuntu,Debian
Posts: 381

Rep: Reputation: 30
Glad you got it sorted. Its a very strange and frustrating thing this problem. When I had it I ended up just fiddling round with those directives until it worked!

Well done
 
  


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
Virtual Hosting? nr5 Linux - Software 10 06-03-2005 01:30 PM
virtual hosting setenv02 Linux - General 6 05-05-2005 02:35 AM
Virtual Hosting Thom_Redhat Fedora 0 01-14-2005 07:26 AM
Virtual hosting... id10t Linux - Networking 4 02-02-2004 05:43 PM
Virtual Hosting marson Linux - General 2 12-28-2000 08:14 PM


All times are GMT -5. The time now is 01:52 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration