Write Privileges - localhost - Mac OSX

I found the best solution was to change the apache user and group settings. The instructions can be found at: http://paulmason.name/item/change-apache-user-group-in-lion-os-x

  1. Open Terminal and Enter

    sudo nano /private/etc/apache2/httpd.conf
    
  2. Find and change http.conf code from

    User _www
    Group _www
    

    To

    User your_mac_username
    Group staff
    

    Note: With earlier versions such as Leopard, capitalize staff to Staff. You can get your username and group by typing "id" and hitting enter in terminal

  3. Restart Apache

    sudo apachectl restart
    

I'm running Apache on OSX and this fixed it for me:

sudo chown -R _www:_www <mywebfolder>
sudo chmod -R 775 <mywebfolder>

Update #1:

Syntax: sudo chown <user>:<group> <file-or-folder>. The Apache user on OSX is _www.

To keep ownership but give Apache r-w-x permissions:

sudo chown -R <your-username>:_www <mywebfolder>
sudo chmod -R 775 <mywebfolder>

Update #2:

I like this method best. Set Apache to run as you.

  1. In terminal type id to get uid=123(Myname).

  2. Open /etc/apache2/httpd.conf and edit it to use your username.

    <IfModule unixd_module>
       User Myname
       Group staff
    </IfModule>
    
  3. Back to terminal: sudo apachectl restart


I'm the author of the mentioned blog post. For web server file permissions, you'll want to give write access to the _www user for files. For config.inc.php, you would set it a couple ways:

Have _www own the file and have write permissions:

$ sudo chown _www config.inc.php
$ chmod u+w config.inc.php

Have your user own the file, change the group to _www, and give group write permissions:

$ sudo chgrp _www config.inc.php
$ chmod g+w config.inc.php

Or, if you feel comfortable allowing all users to write, which I would not recommend for security reasons, give all users the ability to write:

$ chmod a+w config.inc.php

If an entire folder needs to be written by the _www user, it can own the folder and all files:

$ sudo chown -R _www:_www folder/

or you can give the folder write and execute permissions by all:

$ chmod a+wx folder/

The reason why chmod 774 gave you forbidden errors was because the _www user fell under the '4' permission, which is 'read-only.' For directories, a user needs 'execute' in order to traverse into the folder. chmod 775 would allow user and group to rwx, and others to r-x. Here's more information on Unix file permissions.

Also, your user could retain full ownership and add certain permissions for the _www user instead of changing the level of access for ALL users by using Access Control Lists.

$ sudo chmod -R +a '_www allow read,write,delete,add_file,add_subdirectory,file_inherit,directory_inherit' folder
$ sudo chmod +a '_www allow read,write' config.inc.php

If you're going to go the route of ACLs, I'd suggest doing some more reading to see what levels of access you really need to provide. Here is a great place to start.