Laravel

Laravel error Failed to open stream: Permission denied

I don’t remember acutally if I faced this issue while runing my Laravel 5.6 app in Homestead or not. But as I deployed app to the staging and production with DigitalOcean after running composer install, preparing .env for production and clearing cache. When I opened my app in browser got following error:

FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught ErrorException: file_put_contents(/var/www/app/storage/framework/views/....php): failed to open stream: Permission denied in ... vendor/laravel/framework/src/Illuminate/Filesystem/Files

This only happens when app is set for other than local, test environment.
APP_ENV=(local to production)

This permission issue can be resolved by running following command.

sudo chown -R www-data:www-data storage

Author: Danyal
I'm skilled programmer with expertise in Vue.js/Nux.js for front-end development and PHP Laravel for back-end development. I excel in building APIs and services, and also have experience in web server setup & maintenance. My versatile skill set allows you to develop and maintain web applications effectively, from the user interface to the server-side functionality. I love coding with never ending learning attitude, thanks for visiting danya.dk