Centos 7/Apache/PHP - Mkdir(): Permission Denied

Centos 7 / Apache / PHP - mkdir(): Permission denied

Could be that although you have 755/777 permissions, SELinux is blocking httpd from writing/creating dirs.

Try:

chcon -R -t httpd_sys_content_t /path/to/www
chcon -R -t httpd_sys_content_rw_t /path/to/www/dir/for/rw

Further info: http://wiki.centos.org/TipsAndTricks/SelinuxBooleans

PHP Warning: mkdir(): Permission denied in Seperate filesystem

Edit your apache -> conf -> httpd.conf file & change User and Group from daemon to your machine owner name. (in your case: a-linux-user) See if that works.

Can't seem to get correct permissions for mkdir() in PHP

The reason for this is the script needs write permissions in sample_folder.

I don't know your actual set up, but I'm guessing your script is either running under world permissions or group permission which is 5 (read 4 + execute 1) since your current permissions are 755 (7 for owner, 5 for group and 5 for world). To write directories into that folder, your script will need write access. You can set this up more securely than 777 if you have access to chown directories. My advice would be to create a group called 'webgroup' or similar and place your webserver user into that group. Then, give the group write permissions (770) would be appropriate once you have that set up. In case you're a little hazy on how the permissions work, the final setup would be:

sample_folder: owned by root, group webgroup, 770 permissions
add whatever user apache (or other webserver) is running as to webgroup

EDIT:

With more details available in the initial post, this means you would be adding the user 'apache' to webgroup. If you find this too difficult a setup or you do not have full permissions on the server to set this up then using chown as suggested elsewhere to let apache own the directory would work as well.

For example: chown apache sample_folder

This will make apache the owner of the folder, giving it access to write permissions (assuming it is still 755)



Related Topics



Leave a reply



Submit