Search code examples
macosapachelocalhostosx-mavericksvhosts

OS X 10.9 Mavericks - Localhost Setup with VHosts


I have just been trying to setup a local apache server on osx. Everything was going well until I enabled vhosts.

When I navigate to a site setup in vhosts (local.dev) all I get is a 403 forbidden error saying you do not have permission to access / on this server.

The route of the site in question is '/www/local/public/'. The folder path exists and running apachectl -S and the syntax of the vhosts file was correct.

I have looked at the permissions of the folder and have even tried setting everyone to read and write, but no luck. I have set my permissions on the folder to read/write as well as permissions for the _www group.

If you have any ideas on where I am going wrong that would be much appreciated!

I have looked for a few answers on here but not been able to find anything that has worked for me.

Looking at the default document root for apache, the only permission I have missing on the /www/ folder is for an account called 'system'. I am unable to add this system account to the permissions of the folder as it does not appear in the get info option on the folder.

Thanks,

Joe


Solution

  • As with all of my questions it seems, I have found an answer!

    I managed to get everything working smoothly by adding the following to my /private/etc/apache2/extra/httpd-vhosts.conf file inside of the <VirtualHost *:80> that was setup for local.dev

    <Directory "/www/local/public">
        Options Indexes FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
    

    So the overall vhosts config for local.dev would look like the following:

    <VirtualHost *:80>
        DocumentRoot "/www/local/public"
        ServerName local.dev
        <Directory "/www/local/public">
            ... Above code here ...
        </Directory>
    </VirtualHost>
    

    I added this, then restarted apache, and everything worked smoothly.