Sign up ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I'm trying to set a local environment on my new MacBook Air 13": built-in Apache with my own DocumentRoot, PHP, and MySQL. I usually update /etc/hosts just to run my local websites with a pretty permalink: local/example. For references, I usually check:

This time I'm simply getting a 403 Forbidden error every time I hit, localhost, or local. First I saw through the terminal that both Apache and PHP are running (even though I can't view PHP pages); then I updated all permissions according to Apache permissions; now I'm just desperate. Here are the relevant Apache configs:

  • /etc/hosts (view file — added one line)
  • /etc/apache2/httpd.conf (view file — updated the DocumentRoot)
  • /etc/apache2/users/joao.conf (view file — created this file)
  • /etc/apache2/extra/httpd-vhosts.conf (view file — updated VirtualHost)

It looks like Apache is somehow denying me access to my DocumentRoot (which by the way is ~/Sites). Because ~/Sites is actually a symlink, I then tried to update DocumentRoot with the following paths (all pointing to the same directory):

  • ~/Sites
  • /Users/joao/Sites
  • /Users/joao/Dropbox/Workflow/Sites (the original directory)

Still throwing 403. Any ideas how to fix/debug this?

Quick update — here's what my /var/log/apache2/ looks like:

[Sun Jul 07 12:50:45 2013] [error] [client] (13)Permission denied: access to / denied
[Sun Jul 07 12:50:45 2013] [error] [client] (13)Permission denied: access to /favicon.ico denied
[Sun Jul 07 12:50:45 2013] [error] [client] (13)Permission denied: access to /favicon.ico denied
[Sun Jul 07 12:50:45 2013] [error] [client] (13)Permission denied: access to /favicon.ico denied
[Sun Jul 07 12:50:47 2013] [error] [client ::1] (13)Permission denied: access to / denied
[Sun Jul 07 12:50:47 2013] [error] [client ::1] (13)Permission denied: access to / denied
[Sun Jul 07 12:50:48 2013] [error] [client ::1] (13)Permission denied: access to /favicon.ico denied
[Sun Jul 07 12:50:48 2013] [error] [client ::1] (13)Permission denied: access to /favicon.ico denied
share|improve this question

4 Answers 4

I have an alias specified in OSX server pointing to a user directory. I spent a long while chmodding and messing with _www user, adding executable permissions recursively, uninstalling macports and all sorts of stuff trying to get this to work. No idea why it wasn't working.

Eventually, I just checked the "shared folder" checkbox in the Finder for that folder, and it worked, on the specified domain, with php active, the way I wanted it to. :/ that was easy.

share|improve this answer
up vote 4 down vote accepted

I just solved my issue by setting permissions not only to the DocumentRoot directory, but also to all its parent directories. This is how I did it.

share|improve this answer
Could you summarize the basic points in your answer? Thanks! – Matt Jul 3 '14 at 22:09
Granting access to all its parent directory would be a huge security infringement! – Julian Dec 24 '14 at 1:41

I generally fix this by setting the Apache user to myself in local environments and in machines where the only user who uses Apache is me. In /private/etc/apache2/httpd.conf, set User to your username from _www, e.g.:

User _www


User joao

And then restart Apache:

$ sudo apachectl restart

Additional steps:

  1. If you have active sessions, they are going to give permission errors since they are still owned by _www. Own them:

    $ sudo chown joao: /var/tmp/sess_*


After this, Apache (and PHP et al.) will run as you and will gain read/write permission to all of the files you have read/write permission. But since this is just a local development environment, that shouldn't be a problem unless you have no rules to block Apache in your firewall and let questionable files like file explorers, shells, scripts that may contain vulnerabilities run under Apache; in which case anyone including your public wifi neighbor in a cafe can enter http://<your IP> and do whatever those scripts let them to do.

In fact, you should prevent this regardless of the scripts you run or even if you don't set Apache user to yourself since you probably don't want random outsiders to be able to see the contents of your localhost.


  1. Make Apache listen only to localhost. Again, in httpd.conf:

    Listen 80



    And restart Apache again:

    $ sudo apachectl restart
  2. Disable Apache in the application firewall (note that you may have already disabled it if you clicked Deny if/when it was asked during the first time you run Apache):

    1. Open System Preferences » Security & Privacy » Firewall.
    2. Click the lock icon to the lower left and enter your password if needed.
    3. Turn the firewall on if it's disabled.
    4. Click Firewall Options.
    5. Click the + button.
    6. Hit cmd ⌘ + ⇧ shift + G and enter /usr/sbin/httpd and click Add (If httpd doesn't show up there, you can look for it in the terminal by which httpd)
    7. In the list click httpd and select Block incoming connections.
    8. Hit OK.
    9. Reload the firewall:

      $ launchctl unload /System/Library/LaunchAgents/
      $ sudo launchctl unload /System/Library/LaunchDaemons/
      $ launchctl load /System/Library/LaunchAgents/
      $ sudo launchctl load /System/Library/LaunchDaemons/
  3. Restrict PHP to the document root. In php.ini:

    open_basedir = /Users/joao/Sites/:/var/tmp/

    (/var/tmp/ is for sessions)

Use all three solutions to secure yourself in case one of them gets disabled for some reason.

- Note that as my active language in my machine is not English right know, wording might be a little different (Menu options and wording can be different regardless of the language in various OS X versions).

- Lines starting with $ need to be entered in command line (Terminal or iTerm etc), with the $ removed.

share|improve this answer

I was using ACL's to set permissions, following the instructions in "How to Set File and Directory Permissions for Apache on Mac OS X", but still getting:

[Wed Feb 12 15:43:51 2014] [error] [client ::1] (13)Permission denied: access to /trace/trace.php denied (filesystem path '/Library/WebServer/Documents/trace/trace.php') because search permissions are missing on a component of the path

Then I read "(13) Permission Denied" (linked to in João Ramos's answer) and tried adding "execute" to the ACL. That worked.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.