Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

What's the content of your 2nd site?

There are two possible reasons:

  1. 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.

  2. 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

<Directory "/Users/harryg/Sites/sites/%1">

to

<Directory "/Users/harryg/Sites/sites">

Does it work?

share|improve this answer
    
Thanks for the suggestions. All my directories have index docs so that shouldn't be the problem. I tried your 2nd suggestion and restarted apache and now nothing works, including localhost and 127.0.0.1. I can ping foo.dev and I get a response which suggests that's dnsmasq doing its thing but I can't figure out why the whole webserver now seems down. (Running apachectl -t gives syntax OK) –  harryg Dec 17 '13 at 9:30
    
Can you show us your error.log (its path can be found in httpd.conf, like ErrorLog "logs/error.log")? –  ChiChou Dec 17 '13 at 11:47
    
logs posted but nothing from just now. Weirdly apache starts fine and checks out ok in terminal but it might as well not exist now when trying in a web browser –  harryg Dec 18 '13 at 0:34
    
As per latest edit, server now works but still no access to dynamic vhosts –  harryg Dec 18 '13 at 0:47
    
Try the updated part. P.S. Check out the offcial wiki for this problem: wiki.apache.org/httpd/ClientDeniedByServerConfiguration –  ChiChou Dec 18 '13 at 2:02
show 3 more comments

the 403 error states for access denied. You have to check the permissions on the tree directory up to the site directory.

Make sure that the user running apache has read and execute permissions for the directories and read for files.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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