以前使用的是ubuntu系统,最近换了fedora用,LNMP下以前项目运行没问题,这次不行了,查看php-fpm(tail /var/log/php-fpm/www-error.log
)的错误日志如下:
[19-Nov-2015 13:52:42 Asia/Shanghai] PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/usr/share/nginx/wakav/storage/logs/laravel-2015-11-19.log" could not be opened: failed to open stream: Permission denied' in /usr/share/nginx/wakav/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:87Stack trace:#0 /usr/share/nginx/wakav/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php(88): Monolog\Handler\StreamHandler->write(Array)#1 /usr/share/nginx/wakav/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\Handler\RotatingFileHandler->write(Array)#2 /usr/share/nginx/wakav/vendor/monolog/monolog/src/Monolog/Logger.php(289): Monolog\Handler\AbstractProcessingHandler->handle(Array)#3 /usr/share/nginx/wakav/vendor/monolog/monolog/src/Monolog/Logger.php(565): Monolog\Logger->addRecord(400, 'exception 'Symf...', Array)#4 /usr/share/nginx/wakav/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(47): Monolog\Logger->error('exception 'Symf...') in /usr/share/nginx/wakav/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 87
后来请运维的高手看了下说是Selinux的问题,把Selinux关闭掉重启就好了。
查看Selinux状态: 1、/usr/sbin/sestatus -v ##如果SELinux status参数为enabled即为开启状态SELinux status: enabled
2、getenforce
##也可以用这个命令检查(这个没试过)
关闭SELinux:
1、临时关闭(不用重启机器):
setenforce 0 ##设置SELinux 成为permissive模式 ##setenforce 1 设置SELinux 成为enforcing模式
2、修改配置文件需要重启机器:
修改/etc/selinux/config 文件
将SELINUX=enforcing改为SELINUX=disabled
重启系统即可
Author:leedaning