I am having some permissions problems with mkdir in PHP. I am trying to simply move some files around (and create a folder to put them in), but I am getting this error:
mkdir() [function.mkdir]: Permission denied in
On my old site, I had my folders set to 755 and things seemed to work fine. It seems like the only time I can get mkdir or related functions to work on this server is when folders have 777 as their mode.
Is the web browser considered “Others”? I don’t feel like leaving my folders at 777 is a great idea, right?
If you need to create folders on your server that you can then write to from your web browser you may need to use at least 775. Note that this isn’t necessarily the case for creating files. In fact, you probably don’t want your files to be 777 at all.
You can also use bash commands within the php code if you would like to avoid having your server (aka www-data) create the directories but you’ll still need to place the correct permissions on the folders to allow www-data to then write files to the directories.
Do check your ownerships. The above is based on a folder being owned by some user and group owned by www-data. You can also try to set the folder ownership to www-data but the permission would still be rwx for that particular user.
I hope that’s not way to convoluted.
Commands that might help you find out who is running apache on your server:
look for something like:
or
look for something like