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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 16:07:56  来源:igfitidea点击:

Laravel failed to open stream: Permission denied

phplaravellaravel-5ini

提问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 chmodon storageand bootstrap/cache/to 775. I also have a storage/framework/viewsdirectory, I have also tried deleting storage/logs/laravel.log.

我已经做chmodstoragebootstrap/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_contentsseems to be the issue.

注意该脚本在我以前的共享托管计划中运行良好,只有带有 a 的页面file_get_contents似乎是问题所在。

The file in question is ErrorExceptionin PostController.php line 17: where I'm using a file_get_contentscall.

有问题的文件ErrorExceptionPostController.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

From: https://blog.lysender.com/2015/07/centos-7-selinux-php-apache-cannot-writeaccess-file-no-matter-what/

来自:https: //blog.lysender.com/2015/07/centos-7-selinux-php-apache-cannot-writeaccess-file-no-matter-what/

回答by Abhijeet Umbarkar

I think you have set wrong permissions. Give 777 permissions instead of 775 to bootstrap\cache and storage directory. Please have a look here.

我认为您设置了错误的权限。为 bootstrap\cache 和存储目录授予 777 权限而不是 775。请看这里。