Hello,
I'm having a strangely difficult time setting up a subdomain (x.example.com). The main site works fine, but I get 404 errors attempting to hit x.example.com no matter how I set up the VirtualHost config.
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.example.com
DocumentRoot /var/www/example.com/htdocs
ServerAlias example.com
</VirtualHost>
<VirtualHost *:80>
ServerName x.example.com
ErrorLog /var/logs/x-error-log
CustomLog /var/logs/x-access-log common
DocumentRoot /var/www/x/htdocs
</VirtualHost>
As far as I can tell, this is a vanilla set up. Any suggestions would be appreciated.
-
My guess is that access is not allow to the DocumentRoot for the new VirtualHost. You need to add something like the following to your Virtualhost setting.
<Directory "/var/www/x/htdocs"> Options Includes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory>By default, access to the filesystem is denied; you likely have something like this somewhere in your config file(s):
<Directory "/"> Options FollowSymLinks AllowOverride None order allow,deny deny from all </Directory>Hope this helps
Aaron : That didn't fix it either. The new config looks like this:ServerName x.example.com ErrorLog /var/logs/x-error-log CustomLog /var/logs/x-access-log common DocumentRoot /var/www/x/htdocs Options -Indexes FollowSymLinks MultiViews AllowOverride All Allow from all Urgoll : Can you look at /var/logs/x-access-log and confirm that you are indeed accessing the correct virtualhost when you access x.example.com? Then look at the corresponding line in /var/logs/x-error-log which could explain why the 404.From Urgoll -
Try adding
Alias x /var/www/x/htdocsto your main site. This will enable you to see the x content from your main site if it is available.404 often occurs if the directories or files can not be read. Check directory permission on the file system. The directories need permission like 755 or 750 depending on the group. Files need permissions like 644 or 640 depending on the group. Generally the web server's id (opten apache or www-data) should not own the content. It is common to set the group on the content to the web server's group.
Check the directory permission configuration. If it is for /var/www, then both site are covered. If it is for /var/www/htdocs, either setup a copy for /var/www/x/htdocs, or change it to /var/www.
Consider setting the group sticky bit on /var/www/x/htdocs, and doing a recurcive chgrp on it.
From BillThor -
Just to check:
Create an A record in your DNS configuration for your subdomain to resolve to your IP address.
From irms
0 comments:
Post a Comment