Write Privileges - localhost - Mac OSX

前端 未结 5 1793
北荒
北荒 2020-12-07 11:47

I\'m new to the mac world and have just been setting up my webserver. I used the following guide: https://alan.ivey.dev/posts/2011/os-x-10.7-lion-development-native-mamp-wit

5条回答
  •  执念已碎
    2020-12-07 12:18

    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.

提交回复
热议问题