LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-06-2003, 07:06 PM   #1
Cynthia Blue
Member
 
Registered: Dec 2002
Location: SLC Utah USA
Distribution: SuSe 9.1
Posts: 102

Rep: Reputation: 15
Virtual Hosts - whats wrong


Here is how I have my virtual hosts set up for my primary and secondary domain name. It is not directing the 2ndary domain name to the correct directory. I swear I've tried every port/IP/directory combination that exists... gah. What is wrong here? It is insisting I have a Default Virtual Host, and when I change that to specify port 80 apache will not restart. I swear this should work...?

Red Hat 8.

Code:
#
# Use name-based virtual hosting.
#
NameVirtualHost 888.88.88.88
    
#
# Virtual hosts
#

# Virtual host Default Virtual Host
<VirtualHost *:80>
 	DocumentRoot /var/www/html 
 	ServerAdmin cyn@cynthiablue.net
 	ServerName _default_:80
	DirectoryIndex index.php index.html index.htm index.shtml 
 	LogLevel debug
 	HostNameLookups off
</VirtualHost>

# Virtual host domain2.com
<VirtualHost 888.88.88.88>
 	DocumentRoot /var/www/html/ud 
 	ServerAdmin cyn@cynthiablue.net
 	ServerName www.domain2.com
        ServerAlias domain2.com
	DirectoryIndex index.php index.html index.htm index.shtml 
</VirtualHost>
 
Old 01-06-2003, 07:14 PM   #2
te_conway
Member
 
Registered: Apr 2001
Location: MA
Distribution: redhat 7.2
Posts: 182

Rep: Reputation: 30
The wildcard in the 1st virtual host setup accepts all requests. Since there is no ServersAlias it processes everything.
Put a ServerName and ServerAlias in BOTH definitions to differentiate between them right after DocumentRoot.
You can use <VirtualHost *> for both setups
 
Old 01-06-2003, 07:16 PM   #3
te_conway
Member
 
Registered: Apr 2001
Location: MA
Distribution: redhat 7.2
Posts: 182

Rep: Reputation: 30
PS: the ServerName should be a valid domain that points to your IP address.
 
Old 01-06-2003, 07:32 PM   #4
Torm3nt
LQ Newbie
 
Registered: Dec 2002
Posts: 27

Rep: Reputation: 15
hmmm

Firstly:

NameVirtualHost *

It doesn't matter if you have <VirtualHost *>, just as long as you specify the ServerName.

ie.

Code:
### www.example1.com ###
<VirtualHost *>
  DocumentRoot /home/www/example1.com
  ServerAdmin admin@example1.com
  ServerName www.example1.com
</VirtualHost>

### www.example2.com.au ###
<VirtualHost *>
  DocumentRoot /home/www/example2
  ServerName www.example2.com.au
</VirtualHost>

### www.example3.com.au ###
<VirtualHost *>
  ServerAdmin webmaster@example3.com.au
  DocumentRoot /home/www/example3.com.au
  ServerName example3.com.au
</VirtualHost>
Remember that namebased virtual hosting is based off the client browser. It pulls the url it's after from the headers I believe. Therefore, it's not always accurate ( users of older browsers ), but will be fine for 99% of users that hit your site(s).

The above configuration works fine for the 75+ sites i have setup on my linux box, so it should work fine for you. To test domains that don't exist by your account, alter your hosts file in:

windows > system32 > drivers > etc > hosts

and enter:

[ipaddress] domainname.com

then, use "domainname.com" in your browser to test it.

Hope that helps
 
Old 01-07-2003, 11:22 AM   #5
Cynthia Blue
Member
 
Registered: Dec 2002
Location: SLC Utah USA
Distribution: SuSe 9.1
Posts: 102

Original Poster
Rep: Reputation: 15
Thanks for the advice... I gave up last night, I will go home and try the changes tonight.
 
Old 01-07-2003, 05:19 PM   #6
Torm3nt
LQ Newbie
 
Registered: Dec 2002
Posts: 27

Rep: Reputation: 15
not a problem. If you need any more help, continue posting on this thread.
 
Old 01-07-2003, 09:03 PM   #7
Cynthia Blue
Member
 
Registered: Dec 2002
Location: SLC Utah USA
Distribution: SuSe 9.1
Posts: 102

Original Poster
Rep: Reputation: 15
Okay, this is what I have now... seems that my utahdogs.com domain name hangs for a while, then just stops without reaching the correct directory. It still stays on my main domain name's page. I did add the domain name to the /etc/hosts file as well.

Code:
# Use name-based virtual hosting.
NameVirtualHost *

# Virtual host cynthiablue.net
<VirtualHost *>
 	DocumentRoot /var/www/html
 	ServerAdmin cyn@cynthiablue.net
 	ServerName www.cynthiablue.net
        ServerAlias cynthiablue.net
	DirectoryIndex index.php index.html index.htm index.shtml 
 </VirtualHost>

# Virtual host utahdogs.com
<VirtualHost *>
 	DocumentRoot /var/www/html/ud
 	ServerAdmin cyn@cynthiablue.net
 	ServerName www.utahdogs.com
        ServerAlias utahdogs.com
	DirectoryIndex index.php index.html index.htm index.shtml 
</VirtualHost>
 
Old 01-07-2003, 09:25 PM   #8
Cynthia Blue
Member
 
Registered: Dec 2002
Location: SLC Utah USA
Distribution: SuSe 9.1
Posts: 102

Original Poster
Rep: Reputation: 15
Waiting patiently seemed to help. Hung for a while, now it works.. good thing for that tv break.

Thanks for the help.
 
Old 01-07-2003, 10:03 PM   #9
Torm3nt
LQ Newbie
 
Registered: Dec 2002
Posts: 27

Rep: Reputation: 15
hehe.

no problems.
 
  


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
vsftpd, web uploads, vsftpd virtual users, apache virtual hosts, home directories jerryasher Linux - Software 7 02-18-2007 07:29 AM
virtual hosts, virtual ip's? kuplo Linux - Newbie 3 11-29-2005 09:44 PM
whats wrong with my http.conf and virtual hosts kuplo Fedora 1 11-22-2005 01:26 AM
Virtual hosts Help carminejg3 Linux - Newbie 2 12-22-2004 03:47 PM
Whats wrong with this? OlRoy Programming 2 05-28-2003 02:21 PM


All times are GMT -5. The time now is 04:29 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration