我已将 laravel 存储库克隆到我的 CentOS 7 机器上。当我尝试运行它时,出现 500 错误且没有任何显示。
所以我检查一下/var/log/httpd/error_log
我发现我遇到了一些权限错误:
[Mon May 16 11:39:32.996441 2016] [:error] [pid 2434] [client 104.156.67.195:39136] PHP Fatal error: Uncaught UnexpectedValueException: The stream or file "/var/www/html/MYSITE/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /var/www/html/MYSITE/bootstrap/cache/compiled.php:13701
Stack trace:
#0 /var/www/html/MYSITE/bootstrap/cache/compiled.php(13635): Monolog\\Handler\\StreamHandler->write(Array)
#1 /var/www/html/MYSITE/bootstrap/cache/compiled.php(13396): Monolog\\Handler\\AbstractProcessingHandler->handle(Array)
#2 /var/www/html/MYSITE/bootstrap/cache/compiled.php(13494): Monolog\\Logger->addRecord(400, Object(Symfony\\Component\\Debug\\Exception\\FatalErrorException), Array)
#3 /var/www/html/MYSITE/bootstrap/cache/compiled.php(13189): Monolog\\Logger->error(Object(Symfony\\Component\\Debug\\Exception\\FatalErrorException), Array)
#4 /var/www/html/MYSITE/bootstrap/cache/compiled.php(13160): Illuminate\\Log\\Writer->writeLog('error', Object(Symfony\\Component\\Debug\\Exception\\FatalErrorException), Array)
# in /var/www/html/MYSITE/bootstrap/cache/compiled.php on line 13701
我已采取以下措施来尝试克服这些问题:
chmod -R 775 storage
chmod -R 775 vendor
chown -R apache:apache storage
所以现在显示如下:
-rwxrwxr-x. 1 apache apache 2156 May 16 11:41 storage/logs/laravel.log
但这没有用。
有趣的是,我输错了一些artisan
之前的命令和那些似乎将日志添加到日志文件中......
我已经阅读/尝试过:
- “laravel.log”无法打开:无法打开流 https://stackoverflow.com/a/24055227/1007638
- 错误:laravel.log 无法打开 https://stackoverflow.com/questions/23411520/error-laravel-log-could-not-be-opened
- 日志文件权限问题 https://laracasts.com/discuss/channels/laravel/log-file-permission-problem
事实证明问题出在selinux
我找到了这个答案 https://laracasts.com/discuss/channels/laravel/laravel5-gives-blank-page-with-500-status-code-on-apache-fedora22/replies/98874,这解决了我的问题。
通过关闭来证明这是问题所在selinux
用命令
setenforce 0
这应该允许写入,但您已经关闭了附加安全性
服务器范围内。那很糟。恢复 SELinux
setenforce 1
然后最后使用 SELinux 允许使用这个来写入文件
命令
chcon -R -t httpd_sys_rw_content_t storage
你走了!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)