简体   繁体   中英

Laravel failed to open stream: Permission denied

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 .

NB The script worked well on my former shared hosting plans and only the page with a file_get_contents seems to be the issue.

The file in question is ErrorException in PostController.php line 17 : where I'm using a file_get_contents call.

Try running

php artisan config:cache

and then

php artisan env

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

On 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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM