Trying to create subdomain with Apache2
I’m using Ubuntu 10.04 and Apache2.2 on a Linode VPS – I’m trying to create a subdomain sub.mysite.com of mysite.com. I’ve added this entry to /etc/apache2/sites-enabled:
<VirtualHost *:80>
ServerAdmin email@gmail.com
ServerName mysite.com
ServerAlias sub.mysite.com
DocumentRoot /srv/www/sub.mysite.com/public_html/
ErrorLog /srv/www/sub.mysite.com/logs/error.log
CustomLog /srv/www/sub.mysite.com/logs/access.log combined
</VirtualHost>
and this line to /etc/hosts:
127.0.0.1 sub.mysite.com
and created a DNS zone file pointing to sub.mysite.com…
I can successfully ping sub.mysite.com but can’t get index.html to load in my browser…
Any ideas?
Since you’re using virtual hosts, make sure to put this subdomain container BEFORE your main virtual host container. What ever comes first trumps whatever comes after, so if your file looks like this, it won’t work:
<virtualHost *:80>
{snip}
ServerAlias *.mysite.com
DocumentRoot /srv/www/mysite.com/public_html/
{snip}
</virtualHost><VirtualHost *:80>
{snip}
ServerAlias sub.mysite.com
DocumentRoot /srv/www/sub.mysite.com/public_html/
{snip}
</VirtualHost>
Make sense? You have to flip them, so that the 2nd VirtualHost container in my example is first. If that’s not the problem, and you’ve already done this, then check the Apache error log (actually, that should be your first step, regardless).
Also, make sure file permissions are correct.
Check more discussion of this question.
Related posts:
Leave a comment
Recent Posts
- Is there a way for administrators to disable users from installing Firefox extensions?
- Is there research material on NTP accuracy available?
- How to create a limited “domain admin” that does not have access to domain controllers?
- Can Windows RDC admin users be immune from being kicked?
- Domain Administrators account policy (After PCI audit)





