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

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/wwwchcon -R -t httpd_sys_content_rw_t /path/to/www/dir/for/rw

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


Not sure but your Centos's PHP binaries may have broken file permissions. There are two ways to fix this up.

  • Compiling PHP from scratch. I would prefer this since all the control will be yours.
  • Or Changing your php script to use Umask() function of PHP. Documentation link


According to DRU Response

This issues is due to SELINUX. Use bellow command

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