mac osx permission error - apache folder chown _www

8,776

There's no single "correct" way to set this up; what the permissions need to be depends on who should be allowed to do what to which files. Does anyone other than you need to be able to edit the web files? Is it ok if other users on the computer can read the web files (directly, as opposed to via the webserver)?

Here's a simple option that gives you full (read+write) access, lets the webserver read the files, and locks everyone else out of the web folder (note: replace "sandro" with your actual username):

sudo chown -R sandro:_www /Library/WebServer/Documents
chmod -R u=rwX,g=rX,o= /Library/WebServer/Documents

If you need other access rules for the web files, please clarify.

Share:
8,776

Related videos on Youtube

Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin almost 2 years

    I deleted Library/WebServer/Documents folder and created it again.

    When I visited localhost it gave me forbidden error.

    I ran sudo chown _www:_www Documents

    And forbidden error was gone, but now I couldn't edit files at all. I couldn't even go into Documents folder from GUI.

    Any ideas what is correct way to set this up??

    ty.

  • Gordon Davisson
    Gordon Davisson over 11 years
    chmod 777 is almost always the wrong answer -- it's a bit like having a little trouble with one of your door locks, and "solving" the problem by leaving the door wide open all of the time.
  • nerdwaller
    nerdwaller over 11 years
    Generally I would agree, but for presumably local web development, not really a huge issue.
  • Admin
    Admin over 11 years
    I also tried sudo chown -R sandro:_www /Library/WebServer/Documents, in this situation I get forbidden error when visiting localhost.
  • Gordon Davisson
    Gordon Davisson over 11 years
    Did you also do the chmod command? If you're still having trouble after that, post the results of ls -lea /Library/WebServer/Documents so we can see what's going on.
  • Admin
    Admin over 11 years
    Yes it was chmod problem. Eventually I just did permission check on disk and it fixed it for me. And yes your solution was correct, thanks!