I have searched this site and could not find the answer for my simple problem. I setup apache2, php 5, and mysql 5.1 on Red Hat Enterprise Linux 4 (x86_64). Currently, I set it up so that http://mysite.company.com points to our production version of our site. What I want to do is setup http://dev.mysite.company.com to point to our development environment. I tried as such:

$ cat /usr/local/apache2/conf/http.conf
...
NameVirtualHost *:80

<VirtualHost *:80>
    ServerName mysite.company.com
    DocumentRoot "/var/www"
</VirtualHost>

<VirtualHost *:80>
    ServerName dev.mysite.company.com
    DocumentRoot "/var/wwwdev"
</VirtualHost>
...

Now, http://mysite.company.com works, but http://dev.mysite.company.com is not found. Should I talk to the IT people to add dev.mysite.company.com to their DNS look up table? What did I do wrong here? You help is appreciated. Thanks.

link|improve this question

feedback

3 Answers

up vote 1 down vote accepted

Please verify first that there a DNS record that point to your vhost. After add the following to the httpd.conf at the last line


Include /etc/httpd/conf/site-enabled/
Create the directory site-enabled that will contain our vhost config files

sudo mkdir /etc/httpd/conf/site-enabled/

Create the file /etc/httpd/conf/sites-enabled/mysite_company_com.conf


<VirtualHost mysite.company.com>
   ServerName mysite.company.com
   ServerAdmin admin@company.com
   DocumentRoot /var/www
   ErrorLog /var/log/apache2/mysite.company.com-error.log
   CustomLog /var/log/apache2/mysite.company.com-access.log common

</VirtualHost>

and add the line above to /etc/httpd/conf/sites-enabled/dev_mysite_company_com.conf:

<VirtualHost dev.mysite.company.com>
   ServerName mysite.company.com
   ServerAdmin admin@company.com
   DocumentRoot /var/wwwdev
   ErrorLog /var/log/apache2/dev.mysite.company.com-error.log
   CustomLog /var/log/apache2/dev.mysite.company.com-access.log common
</VirtualHost>

At last restart apache.

link|improve this answer
feedback

You will definitely need dev.mysite.company.com to have an A record setup in DNS to get this configuration working. If it doesn't resolve, your browser has no way to know what IP to request the website from.

link|improve this answer
feedback

Yes, the sub-domain will need a valid A or CNAME record in DNS.

link|improve this answer
you can get around this by using /etc/hosts OR doing manual requests. Apache just looks at the headers, so it'll work if you do something like 'telnet $host 80' and then 'GET dev.mysite.company.com/';. this of course, sucks for production. – neoice Oct 16 '09 at 13:40
feedback

Your Answer

 
or
required, but never shown

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