apachehttp-status-code-403vhostserror-logmod-vhost-alias

apache config VirtualDocumentRoot


I have this configuration in my httpd-vhosts.conf:

<Directory "/Users/uername/Library/Mobile Documents/com~apple~CloudDocs/Sites">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
    Require all granted
</Directory>
<Virtualhost *:80>
    VirtualDocumentRoot "/Users/uername/Library/Mobile Documents/com~apple~CloudDocs/Sites/_localhost"
    UseCanonicalName Off
</Virtualhost>
<Virtualhost *:80>
   VirtualDocumentRoot "/Users/uername/Library/Mobile Documents/com~apple~CloudDocs/Sites/%2"
   ServerName sites.dev
   ServerAlias www.*.dev
   ServerAlias www.*.dev.*.xip.io
   UseCanonicalName Off
</Virtualhost>
<Virtualhost *:80>
    VirtualDocumentRoot "/Users/uername/Library/Mobile Documents/com~apple~CloudDocs/Sites/%1"
    ServerName sites.dev
    ServerAlias *.dev
    ServerAlias *.dev.*.xip.io
    UseCanonicalName Off
</Virtualhost>

When I try to access my website, I get a 403 forbidden page. When I look into the apache error log I see this:

[Sun Jun 26 12:09:12.310868 2016] [core:error] [pid 1272] (13)Permission denied: [client 127.0.0.1:50110] AH00035: access to /favicon.ico denied (filesystem path '/Users/username/Library/Mobile Documents') because search permissions are missing on a component of the path, referer: http://site.dev/

I don't fully understand why the path stops at Mobile Documents. All the folders do exist, I do have an index.php file in my root and nothing else explains the 403 error as well.

What am I missing here? How can I solve this problem?


Solution

  • Ah, I solved the problem. Might not be the best way but it works, so if anyone has a better idea, please share. My solution: I changed the user and group apache was running from _www to my own username and group. I used this solution: https://coolestguidesontheplanet.com/forbidden-403-you-dont-have-permission-to-access-username-on-this-server/

    Changing The Apache Web User

    One of the frustrations of using the Users/username/Sites folder is the permissions issues with things like updates and authentication.

    This is because the default webserver user which runs httpd is known as _www, which will not be the user in your local account. If your machine is only in use by you and the webserver will run only under your account then you can change the user.

    Change this back in /etc/apache2/httpd.conf

    osx-yosemite-webserveruser

    Just change it to your username and group, group will be staff and restart Apache

    sudo apachectl restart