16

The error is mention in below:-

ErrorException in Filesystem.php line 81: file_put_contents(/var/www/html/Training-management-system/storage/framework/views/bcb68ba8b65b7fabca5fe88709fb00b6): failed to open stream: Permission denied 

I can google itbut not get the exact solution. SO I am thankful if anyone help me to solve it out.

1
  • Laravel needs permissions to write in storage. Take a look here laravel-recipes.com/recipes/43/… and let us know if this fixed the problem. Commented Jun 28, 2015 at 11:29

7 Answers 7

36

is a file permissions issue as lesssugar said , you need to give writte permissions to the storage folder , so go to your html/Tranining-management-system.. folder an then you can do :

chmod -R 0777 storage/ 

That will change to writte access Recursively .

Please read the configuration section in docs :

http://laravel.com/docs/master#configuration

You have to do the same with the cache folder.

Sign up to request clarification or add additional context in comments.

4 Comments

It also worked for me removing the existing files in storage/framework/views
chmod -R 775 storage/ also works for me. If you use laravel/passport, don't forget to use chmod 664 storage/*.key for oauth keys
Could this possibly open up security concerns?
I dont understand why this comment has been approved and has so many upvotes. 777 permissions is a massive security risk as people outside of www-data group can manipulate the files in the directory. The appropriate method would be to ensure it has the correct write perms or run php artisan view:cache accordingly.
10

I run php artisan view:cache and it solved the issue

Comments

1

This is an error with the view file cache. Please run php artisan view:cache

Comments

1

I had the same issue with Laravel running in a docker container. I checked and the www-data group didn't had permissions nor ownership on the directory.

The chown command allows you to change the user and/or group ownership of a given directory.

chown -R www-data:www-data storage/ 

Keep in mind that chmod -R 777 storage/ permissions is a massive security risk. Normally users outside www-data group should not be able to manipulate files. This is just a workaround for development environments and should be avoided on production environments.

Comments

1

Never use 777, use 644 for files, and 755 for dirs.

export APACHE_USER=$(ps -ef | grep -E '(httpd|apache2|apache)' | grep -v `whoami` | grep -v root | head -n1 | awk '{print $1}') find . -type f -exec chmod 644 {} \; find . -type d -exec chmod 755 {} \; chgrp -R $APACHE_USER ./storage ./bootstrap/cache chmod -R ug+rw ./bootstrap/cache ./storage/framework/cache storage/framework/sessions ./storage/framework/views 

If you use SELinux set labels:

restorecon -Rv . chcon -R -t httpd_log_t storage/logs chcon -R -t httpd_sys_rw_content_t bootstrap/cache chcon -R -t httpd_sys_rw_content_t storage/framework/cache chcon -R -t httpd_sys_rw_content_t storage/framework/views chcon -R -t httpd_sys_rw_content_t storage/framework/sessions 

Script ready at: https://gist.github.com/NeftaliYagua/825b6ce483b92a296caa0f37e4ff040a

Comments

0

I tried many solutions but didn't get resolved this error.

Just: I have just created views folder in 'storage/framework' and solved it.

Comments

0

I try run php artisan view:cache and it solved this issue

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.