LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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-12-2011, 12:46 PM   #1
tibberous
Member
 
Registered: Oct 2004
Posts: 56

Rep: Reputation: 15
vhosts acting weird


I have a site at:

sub.site.com

I want to other domains to point to it. On the old server, everything was setup through cpanel. On the new server, I have the vhosts file as:

<VirtualHost sub.site.com:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot /home/sites/site
ServerName sub.site.com
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
<VirtualHost domain.com:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot /home/sites/site
ServerName domain.com
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
<VirtualHost domain.net:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot /home/sites/site
ServerName domain.net
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>

It seems like this should work, because all three are pulling from /home/sites/site

But it doesn't work. It also gives a message when I restart apache:

VirtualHost domain.com:80 overlaps with VirtualHost domain.net:80, the first has precedence, perhaps you need a NameVirtualHost directive
 
Old 01-12-2011, 01:16 PM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Hi,

As the message says, you need a NameVirtualHost directive. The usual syntax is
Code:
NameVirtualHost *:80
Using the above notation you need to change the opening VirtualHost tag of the 3 vhosts, like this:
Code:
<VirtualHost  *:80>
Regards
 
Old 01-13-2011, 01:16 AM   #3
tibberous
Member
 
Registered: Oct 2004
Posts: 56

Original Poster
Rep: Reputation: 15
Will it matter that there are other vhosts on the server? It seems like NameVirtualHost *:80 would apply to everything.
 
Old 01-13-2011, 02:17 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
You use the generic NameVirtualHost *:80 and later on when it come to define the vhosts, you use:
Code:
<VirtualHost  *:80>
ServerName sub.site.com
...
</VirtualHost>
<VirtualHost  *:80>
ServerName domain.com
...
</VirtualHost>
<VirtualHost  *:80>
ServerName domain.net
...
</VirtualHost>
and so on for any virtual host you want to add
Running
Code:
httpd -S
should give you details on vhosts.

Regards
 
  


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
OS acting weird MTK358 Linux - Newbie 5 01-07-2010 05:08 PM
apache acting weird Red Squirrel Linux - Software 2 08-19-2005 08:47 PM
cdrom acting weird Vindane Slackware 5 05-30-2004 12:53 AM
Radeon acting weird... r_jensen11 Linux - Hardware 9 05-09-2004 01:41 AM
apache acting weird... Red Squirrel Linux - Newbie 1 03-03-2004 08:29 PM

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

All times are GMT -5. The time now is 02:06 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
Open Source Consulting | Domain Registration