Resolved: CakePHP 3.2 on CentOS 7 file_put_contents Permission denied


#1

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


#2

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.


#3

cakephp root:


#4

cakephp logs:


File_put_contents: failed to open stream: Permission denied
#5

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]


#6

For anyone who doubts I have the correct user:


#7

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


#8

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.


#9

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


#10

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