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

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

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

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


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 Mokaddim 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 Mokaddim 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

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>
  • 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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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