Resolved: CakePHP 3.2 on CentOS 7 file_put_contents Permission denied

Warning (2): file_put_contents(/cakephp/logs/error.log) [function.file-put-contents]: failed to open stream: Permission denied [CORE/src/Log/Engine/FileLog.php, line 134]

I have done this so far to figure out the problem:

chown apache: -R /cakephp
chmod 777 -R /cakephp

It still give me the error

Hi i have this problem in fedora .this error maybe has some sulotion.you must chmod -R 777 cakephp/logs OR you delete anythin in logs folder OR you change chown file.

cakephp root:

cakephp logs:

I am still getting the error:

Warning (2): file_put_contents(/cakephp/logs/error.log) [function.file-put-contents]: failed to open stream: Permission denied [CORE/src/Log/Engine/FileLog.php, line 134]

For anyone who doubts I have the correct user:

Found the answer if anyone else gets this error:

on command line type:

getenforce

If result back = Enforcing then:

edit /etc/selinux/config
Change:
SELINUX="value"
to
SELINUX=disabled

The restart server, but if you do not want to restart then run command:
setenforce 0

2 Likes

Disabling SELinux is NOT the solution. It is like to prevent anti-virus pop ups, disable anti-virus!

setsebool -P httpd_unified 0 try toggling with 1 - More info here

This is a great complied list of Apache booleans.

I renabled SELinux and got the error before.

I then tried setsebool -P httpd_unified 0 to make sure it was already set as 0 and still got the same error.

I then tried setsebool -P httpd_unified 1 and the error went away my CakePHP still works.

I even rebooted to make sure the setsebool stuck and did not have to be set again.

Thanks

Thanks … this command is enough for all the permission issue : setenforce 0

Thank you saved my day :smiling_face_with_three_hearts: