2

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.

3 Answers 3

2

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 this:

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

To this:

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

Does it work?

7
  • 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, 2013 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, 2013 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, 2013 at 0:34
  • As per latest edit, server now works but still no access to dynamic vhosts
    – harryg
    Dec 18, 2013 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, 2013 at 2:02
1

Just ran into this same issue and it turned out to be a default setting in apache. in the httpd.conf is this

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>

remove the "Deny from all" line and restart apache.

0

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.

1
  • 2
    Somewhat correct. It could also mean that the Apache config is denying access. Remember, Apache 403 forbidden does not automatically translate to file system permissions. Oct 4, 2014 at 21:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .