tagni hugues pascal
tagni hugues pascal

Reputation: 57

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.

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.

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

Upvotes: 3

Views: 15264

Answers (3)

user320487
user320487

Reputation:

Try running

php artisan config:cache

and then

php artisan env

Upvotes: 3

JulianoMartins
JulianoMartins

Reputation: 553

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/

Upvotes: 5

Abhijeet Umbarkar
Abhijeet Umbarkar

Reputation: 51

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

Upvotes: 0

Related Questions