403 Forbidden Error when trying to view localhost on Apache
Solution 1:
If you're getting a 403 error it probably means the directory does not exist, or the privileges on that directory won't let you see it.
My problem was that the default virtual host settings were pointing to a directory that didn't exist.
So here's what you should do: (assuming you're on Snow Leopard)
-
Find and open your virtual hosts configuration file.
pico /etc/apache2/extra/httpd-vhosts.conf
-
Check that your virtual host definitions are in there, otherwise create them
<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot "/Users/yourusername/Sites/mysite" ServerName mysite.local ErrorLog "/private/var/log/apache2/mysite-error_log" CustomLog "/private/var/log/apache2/mysite-access_log" common </VirtualHost>
-
Open up
/etc/hosts
file and add your virtual host name. This is what's in mine:## # Host Database # # localhost is used to configure the loopback interface # when the system is booting. Do not change this entry. ## 127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost fe80::1%lo0 localhost # VIRTUAL HOST START 127.0.0.1 localhost 127.0.0.1 mysite.local # VIRTUAL HOST STOP
-
Now restart Apache and you should be good to go!
sudo apachectl restart