'file_put_content...fail to open stream:Permission denied in Laravel 5

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.



Solution 1:[1]

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.

Solution 2:[2]

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

Solution 3:[3]

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

Solution 4:[4]

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.

Solution 5:[5]

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

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

Solution 6:[6]

I have this problem multitime ,first use bellow code in terminal linux:

chmod -R 0777 storage/

If it is not work use write and exec php artisan view:cache in terminal

Or you can remove existing files in storage/framework/views directory

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jezmck
Solution 2 cetric
Solution 3 Kavishka Hirushan
Solution 4 Gustavo Martínez
Solution 5 Gufran Hasan
Solution 6 Amir Hossain Rezavand