Laravel 无法打开流:权限被拒绝
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44533090/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel failed to open stream: Permission denied
提问by tagni hugues pascal
I had a look around and most of the answers weren't for shared hosting which happens to be my case.
我环顾四周,大多数答案都不是针对共享托管的,而这恰好是我的情况。
I've done chmod
on storage
and bootstrap/cache/
to 775
. I also have a storage/framework/views
directory, I have also tried deleting storage/logs/laravel.log
.
我已经做chmod
的storage
和bootstrap/cache/
来775
。我也有一个storage/framework/views
目录,我也试过删除storage/logs/laravel.log
.
N.B The script worked well on my former shared hosting plans and only the page with a file_get_contents
seems to be the issue.
注意该脚本在我以前的共享托管计划中运行良好,只有带有 a 的页面file_get_contents
似乎是问题所在。
The file in question is ErrorException
in PostController.php line 17
: where I'm using a file_get_contents
call.
有问题的文件ErrorException
中PostController.php line 17
:我使用了一个地方file_get_contents
通话。
回答by tagni hugues pascal
Try running
尝试跑步
php artisan config:cache
php artisan config:cache
and then
进而
php artisan env
php artisan env
回答by JulianoMartins
On CentOS 7 + Apache:
在 CentOS 7 + Apache 上:
cd /var/www/laravelfolder
sudo chown apache:apache -R /var/www/laravelfolder
find . -type f -exec chmod 0644 {} \;
find . -type d -exec chmod 0755 {} \;
sudo chcon -t httpd_sys_content_t /var/www/laravelfolder -R
sudo chcon -t httpd_sys_rw_content_t /var/www/laravelfolder/storage -R
sudo chcon -t httpd_sys_rw_content_t /var/www/laravelfolder/bootstrap/cache -R
来自:https: //blog.lysender.com/2015/07/centos-7-selinux-php-apache-cannot-writeaccess-file-no-matter-what/