Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Hi I have this problem with a new rackspace cloud server.

i have an apache where the ServerName is set to mydomain.com the DocumentRoot is /var/www/html

and I have a few virtual hosts too which I want to have in this server

I got a seperate file called hosts.conf in the /etc/httpd/conf.d/ the content of it looks like this

NameVirtualHost *:80 

<Directory /var/domains>
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>     

<VirtualHost *:80>
    ServerName mydomain-1.com
    DocumentRoot /var/domains/mydomain-1.com
    ServerAlias www.mydomain-1.com
    ServerAdmin webmaster@mydomain-1.com
</VirtualHost> 

<VirtualHost *:80>
    ServerName mydomain-2.com
    DocumentRoot /var/domains/mydomain-2.com
    ServerAlias www.mydomain-2.com
    ServerAdmin webmaster@mydomain-2.com
</VirtualHost> 

so the problem is when I add try to access the three websites,

mydomain.com, mydomain-1.com and mydomain-2.com, all of them returns the mydomain.com content.

any help is appreciated

thanks

share|improve this question

migrated from stackoverflow.com Dec 25 '11 at 16:53

This question came from our site for professional and enthusiast programmers.

    
If your OS is debian based, you could use a2makesite code.google.com/p/a2makesite –  Shiplu Dec 24 '11 at 9:43
    
the os is centos –  nivanka Dec 24 '11 at 9:46
    
Do you see any error? My VirtualHost entry is like <VirtualHost *> and I have NameVirtualHost * and Listen 80 in my apache configuration files. –  Shiplu Dec 24 '11 at 9:52
1  
What's the output of /usr/sbin/apache2ctl -t -DDUMP_VHOSTS? –  Linus Kleen Dec 24 '11 at 10:06
1  
Then check the access logs for each domain. If not so configured, then do this. It should tell you whether or not a request actually reaches the vhost and more importantly what the HTTP response code is. –  Linus Kleen Dec 24 '11 at 11:22
show 5 more comments

1 Answer 1

Try NameVirtualHost ing each specifically:

NameVirtualHost mydomain-1.com:80 
NameVirtualHost mydomain-2.com:80 

and add the server name in the VirtualHost directive:

<VirtualHost mydomain-1.com:80>
share|improve this answer
    
that didnt work –  nivanka Dec 24 '11 at 10:04
    
@nivanka are you sure hosts.conf is being parsed? –  Pekka 웃 Dec 24 '11 at 10:05
    
yes it is being parsed –  nivanka Dec 24 '11 at 10:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.