Question

I developed a PHP script to add new files based on a template. I'm running it on localhost by now. I wondered what is the best chmod setting for the folder the script is in (and where the new files should go). 644 says permission denied, 622 works, 666 works (I can only choose 6, 4, 2 and 0 from the Info panel on my mac). By the way, I noticed the third number matters, how can I set it up to be the second or first?

EDIT
So how do you change chown on a Mac for localhost?

Was it helpful?

Solution 2

The third number relates to Everyone (the first two are Owner and Group). 4 is read only which is why that does not work, 2 is write only and 6 is read/write (7 is read/write/execute).

In general, you should not be giving everyone write access to your server. The best approach where write access is required is to use chown to change the owner and/or group to match the user that your webserver is running as, then use 644 or 664.

For Mac, this thread: Correct owner/group/permissions for Apache 2 site files/folders under Mac OS X? provides some pointers on how to do this securely.

If you just want to change your upload folder, try:

sudo chgrp _www /path/to/upload/folder
sudo chmod 664 /path/to/upload/folder

OTHER TIPS

It's not about chmod it's about chown. The owner of that directory should be the web server. Usually the user is apache or www or www-data.
644 Is recommended for files.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top