CentOS 上 Laravel 的权限问题 [英] Permissions Issue with Laravel on CentOS
问题描述
我已经将一个 Laravel 存储库克隆到我的 CentOS 7 机器上.当我尝试运行它时,我收到 500 错误,但没有显示任何内容.
I've cloned a laravel repo to my CentOS 7 box. When I try to run it, I get a 500 error with nothing displayed.
所以我查看了 /var/log/httpd/error_log
并发现我有一些权限错误:
So I check out /var/log/httpd/error_log
and I see that I've got some permissions errors:
[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
为了解决这些问题,我做了以下工作:
I have done the following to try to overcome the issues:
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
命令,这些命令似乎将日志添加到日志文件中...
Interestingly enough, I mis-typed some artisan
commands earlier and those seemed to add logs to the logfile...
推荐答案
原来问题出在 selinux
我找到了这个答案,解决了我的问题.
通过使用命令关闭selinux
来证明这是问题
Prove this is the problem by turning off
selinux
with the command
setenforce 0
这应该允许写入,但您已关闭附加安全性服务器范围.那很糟.转回 SELinux
This should allow writing, but you've turned off added security server-wide. That's bad. Turn SELinux back
setenforce 1
然后最后使用SELinux允许通过使用这个来写入文件命令
Then finally use SELinux to allow writing of the file by using this command
chcon -R -t httpd_sys_rw_content_t storage
你走了!
这篇关于CentOS 上 Laravel 的权限问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!