Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

403 Forbidden on localhost using Apache on OSX

Sorry if this seems trivial but the issue has been holding me up for a long time now and I'm not sure where to go with debugging it. When visiting localhost on my mac dev environment I get a 403 forbidden. Its the default set up, so this should be serving from /Library/WebServer/Documents/

When I nav straight to a file in that folder, same error. When I nav to a file that I know is not there, same error.

Notable settings from /private/etc/apache2/httpd.conf, which appear to be all defaults:

ServerRoot "/usr"
Listen 80
User _www
Group _www
DocumentRoot "/Library/WebServer/Documents"

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

<Directory "/Library/WebServer/Documents">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

Hitting localhost seems to put no entries in /var/log/apache2/error_log but if I set up a new vhosts entry:

<VirtualHost *:80>
    DocumentRoot "/Users/me/Dropbox/work/web/testsite.local"
    ServerName testsite.local
</VirtualHost>

...and in hosts, send testsite.local to 127.0.0.1, I get this in /var/log/apache2/error_log

(13)Permission denied: access to / denied (filesystem path '/Users/me/Dropbox/work') because search permissions are missing on a component of the path

It's really stumping me. Can anyone suggest where to start?

like image 334
tripRev Avatar asked Apr 20 '26 22:04

tripRev


1 Answers

I futzed around with this for hours, and finally realized after comparing my setup to another machine that my httpd-vhosts.conf file had a significant difference.

On the working machine, it had:

<VirtualHost *:80>
        DocumentRoot "/Library/WebServer/Documents"
</VirtualHost>

If you use vhosts, and /private/etc/apache2/extra/httpd-vhosts.conf is missing that crucial part, you will struggle with localhost errors.

like image 71
hisnameisjimmy Avatar answered Apr 22 '26 13:04

hisnameisjimmy