I have followed this guide and am trying to create dynamic vhosts on OSX by allowing foo.dev
to direct to the web folder /foo
. My difference being that I am using ~/Sites
as my web folder instead of the Mac HD as in the guide. It uses dnsmasq which I believe is installed and working correctly.
So in my ~/Sites folder I have:
home
sites
|-foo
|-bar
My httpd-vhosts.conf looks like this:
<Virtualhost *:80>
DocumentRoot "/Users/harryg/Sites/home"
ServerName home.dev
UseCanonicalName Off
ErrorLog "logs/home/error.log"
<Directory "/Users/harryg/Sites/home">
#Options FollowSymLinks
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride None
Allow from all
</Directory>
</Virtualhost>
<Virtualhost *:80>
VirtualDocumentRoot "/Users/harryg/Sites/sites/%1"
<Directory "/Users/harryg/Sites/sites/%1">
Options FollowSymLinks
#Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride None
Allow from all
</Directory>
ServerName sites.dev
ServerAlias *.dev
UseCanonicalName Off
</Virtualhost>
The first vhost works fine and going to home.dev
leads to the example index.php
file I have in the root of that vhost.
The 2nd vhost just gives a 403 Forbidden error for anything.dev, whether or not a folder exists for the subdomain of .dev.
Any ideas?
Edit:
Latest Log entries
Apache Error Log:
[Wed Dec 18 00:45:37 2013] [error] [client 127.0.0.1] File does not exist: /Users/harryg/Sites/home/favicon.ico
[Wed Dec 18 00:45:45 2013] [error] [client 127.0.0.1] client denied by server configuration: /Users/harryg/Sites/sites/test/, referer: http://home.dev/
[Wed Dec 18 00:45:45 2013] [error] [client 127.0.0.1] client denied by server
Server now works (was a problem with error log directory in config file). But still can't access dynamic vhosts.
Best Answer
What's the content of your 2nd site?
There are two possible reasons:
If a directory has no index document (index.php, index.html, default.html, etc) and directory listing is not allowed, Apache will display a 403 error page.
I notice that you didn't enable ExecCGI in sites.dev . Could you try enable it?
Updated: Percent sign in path (
/Users/harryg/Sites/sites/%1
) is for mod_vhost_alias, but not Apache's<Directory>
rules. Modify this:To this:
Does it work?