Laravel could not be opened: failed to open stream: Permission denied

Laravel could not be opened: failed to open stream: Permission denied

When you first setup a laravel project, you might encounter this error 'could not be opened: failed to open stream: Permission denied' or 'PHP Fatal error: Uncaught UnexpectedValueException: The stream or file'.

The error message indicates that you need to give a proper permission for storage folder inside laravel. Laravel uses this folder to store logs, caches, and other things.

You could give permission 777 to folder storage but that is not the right way to do, in real production server you could have serious security issue if you do that.

The correct solution is this:
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache

Just keep in mind, for laravel 4 the storage is located at app/storage/, while laravel 5 storage folder is in the root project folder (outside app folder).


~ cheers ~

1 comments:

This comment has been removed by the author.


EmoticonEmoticon