LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 11-06-2009, 02:11 PM   #1
Chris1989
LQ Newbie
 
Registered: Oct 2009
Distribution: Fedora 11 + CentOS 5.1
Posts: 17

Rep: Reputation: 3
Apache VirtualHost Help


Hey guys, having trouble with virtual hosts on my CentOS run Apache2 server.

my httpd.conf is as follows (changed the domain and user names for security)

Code:
NameVirtualHost *:80

<VirtualHost *:80>
        DocumentRoot /home/user1/domain1.com/public_html
        ServerName domain1.com
        <Directory />
                AllowOverride All
        </Directory>
</VirtualHost>

<VirtualHost *:80>
        DocumentRoot /home/user2/domain2.com/public_html
        ServerName domain2.com
        <Directory />
                AllowOverride All
        </Directory>
</VirtualHost>
Now domain1.com shows the correct files however by going to domain2.com it is showing the files for domain1.com.....

i tried in a different browser incase it was showing a cached page from a previous viewing but its not.

Any suggestions ?

Cheers.
 
Old 11-06-2009, 02:21 PM   #2
teebones
Member
 
Registered: Aug 2005
Location: /home/teebones
Distribution: sometimes this, sometimes that..
Posts: 502

Rep: Reputation: 56
did you setup the dns correctly? does both domains resolve?
 
Old 11-06-2009, 02:27 PM   #3
Chris1989
LQ Newbie
 
Registered: Oct 2009
Distribution: Fedora 11 + CentOS 5.1
Posts: 17

Original Poster
Rep: Reputation: 3
Quote:
Originally Posted by teebones View Post
did you setup the dns correctly? does both domains resolve?
The server has the one IP address and both domains were registered with a seperate company where the DNS have both been changed to point to the servers IP...
 
Old 11-07-2009, 11:42 AM   #4
Chris1989
LQ Newbie
 
Registered: Oct 2009
Distribution: Fedora 11 + CentOS 5.1
Posts: 17

Original Poster
Rep: Reputation: 3
anyone else?
 
Old 11-07-2009, 12:17 PM   #5
WhisperiN
Member
 
Registered: Jun 2009
Location: Middle East
Distribution: Slackware 13.1, CentOS 5.5
Posts: 137

Rep: Reputation: 17
Hellu dude..

Use the next conf, and it should work like a charm..


Code:
NameVirtualHost *:80


<VirtualHost *:80>
    ServerName domain1.com
    ServerAlias domain1.com
    DocumentRoot /home/user1/domain1/public_html
    ServerAdmin admin@domain1.com
    UseCanonicalName Off
    ErrorLog "/var/log/httpd/domain1.com-error_log"
    CustomLog "/var/log/httpd/domain1.com-access_log" common
    ScriptAlias /cgi-bin/ /srv/httpd/cgi-bin/
</VirtualHost>


<VirtualHost *:80>
    ServerName domain2.com
    ServerAlias domain2.com
    DocumentRoot /home/user2/domain2/public_html
    ServerAdmin admin@domain2.com
    UseCanonicalName Off
    ErrorLog "/var/log/httpd/domain2.com-error_log"
    CustomLog "/var/log/httpd/domain2.com-access_log" common
    ScriptAlias /cgi-bin/ /srv/httpd/cgi-bin/
</VirtualHost>

Let me know if it worked for you..

Chelleeeess..

Last edited by WhisperiN; 11-07-2009 at 12:19 PM.
 
Old 11-08-2009, 04:01 PM   #6
Chris1989
LQ Newbie
 
Registered: Oct 2009
Distribution: Fedora 11 + CentOS 5.1
Posts: 17

Original Poster
Rep: Reputation: 3
Quote:
Originally Posted by WhisperiN View Post




Let me know if it worked for you..

Chelleeeess..
Hey, yes its working fine now! Thanks for that, can you see why my conf was not working?
 
Old 11-08-2009, 05:30 PM   #7
WhisperiN
Member
 
Registered: Jun 2009
Location: Middle East
Distribution: Slackware 13.1, CentOS 5.5
Posts: 137

Rep: Reputation: 17
Quote:
Originally Posted by Chris1989 View Post
Hey, yes its working fine now! Thanks for that, can you see why my conf was not working?
Hummm..

I guess you had to include the ServerAlias part..

By the way, some (Thumb Up) would help a lot after a good reply and help

Also, please mark your post as [SOLVED] form the topic (thread) tools.


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
Apache VirtualHost QS helptonewbie Linux - Server 6 07-22-2009 11:33 AM
Apache -VirtualHost davidhk Debian 7 08-19-2005 12:33 PM
Virtualhost setup on apache 2 notmatt Debian 2 10-28-2004 01:05 PM
Help with Apache <VirtualHost> please. smakkythecamel Linux - Networking 2 06-12-2003 07:15 PM
apache virtualhost jonfa Linux - Networking 5 08-12-2002 06:07 PM

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

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