Home » Questions » Computers [ Ask a new question ]

403 Forbidden Error when trying to view localhost on Apache

403 Forbidden Error when trying to view localhost on Apache

I think my Apache must be all screwed up. I don't know if it ever worked. I just upgraded to Snow Leopard, and the first step on this tutorial is to start apache and check that it's working by opening localhost. It starts fine but when I go to localhost I get a 403 forbidden error.

Asked by: Guest | Views: 55
Total answers/comments: 1
Guest [Entry]

"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"