1

I have error as below

But my folder is on 777 and own by the nginx and php-fpm runs as nginx.

Warning: error_log(/var/www/vhosts/example.com/httpdocs/includes/../tmp/logs/error2016-08-10.log): 
failed to open stream: Permission denied in 
/var/www/vhosts/example.com/httpdocs/includes/config.php on line 86

php code that produced the error was

<?php 
error_log($message, 3, __DIR__ . '/../tmp/logs/error' . date('Y-m-d') . '.log');
?>

Any idea on why ? is it open_base_dir "/../" is not working ?

mahen3d
  • 7,047
  • 13
  • 51
  • 103
  • what function caused the error? show us the line – Ibu Aug 10 '16 at 07:35
  • You can quickly find the cause if this kind of problems using this troubleshooting checklist : http://stackoverflow.com/questions/36577020/failed-to-open-stream-no-such-file-or-directory – Vic Seedoubleyew Aug 20 '16 at 08:47

1 Answers1

0

Issue solved by disabling the SELinux

To check if SELinux is running:

$ getenforce

To disable SELinux until next reboot:

$ setenforce Permissive

Restart Nginx and see if the problem persists.

If you would like to permanently alter the settings you can edit

/etc/sysconfig/selinux

Then you need to run

$ chcon -R -t httpd_sys_content_t /var/www/vhosts/
$ systemctl restart nginx.service && systemctl restart php-fpm.service
mahen3d
  • 7,047
  • 13
  • 51
  • 103
  • Next time you can quickly find what is causing the problem using this troubleshooting checklist : http://stackoverflow.com/questions/36577020/failed-to-open-stream-no-such-file-or-directory – Vic Seedoubleyew Aug 20 '16 at 08:47