简体   繁体   中英

Persmission Denied Error on nginx+php-fpm even directory is on 777

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 ?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM