403 Forbidden error on Mac web server

Posted: 27/04/12

An image of 403 Forbidden error on Mac web server

After upgrading Mac OS, or attempting to start the Web Sharing service for the first time, you may find browsing to your document root causes a 403 Forbidden error to display. This is most likely because the Apache web servers HTTP config file is set to disallow access to the root directory - something that Mac OS should probably be automatically updating for you when you activate web sharing, but ah well!

Follow these steps to modify the Apache config to permit access to the root directory on your web server.

1) Open a Terminal and type sudo nano /private/etc/apache2/httpd.conf then press Return

The Apache HTTP config document is opened in the Terminal window.

2) Press Ctrl+W (where is) and type <Directory />

3) Press enter to perform the search.

The cursor moves to the start of the <Directory> block in the document.

4) Change the line Deny from all to Allow from all

5) Press Ctrl+O

6) Press Return to save the changes

7) Press Ctrl+X to close the document and exit back to the Terminal prompt.

8) Type sudo httpd -k restart at the Terminal prompt to restart your Apache 2 server

Now try browsing to your web root.

If that doesn't work:

By default, on any unix based operating system only root can bind a process to a port below 1024.

Your choices are to either use a port higher than 1023 and remember to specify it when you connect, or to ensure that you start Apache as root.

Follow these steps to enable root user on your OSX user account.

Keywords for this post: mac, osx, web server, apache, terminal, lion, snow leopard, mountain lion, http, forbidden