file_put_contents(meta/services.json): failed to open stream: Permission denied

vishnub1626 picture vishnub1626 · May 8, 2014 · Viewed 362.7k times · Source

I am new to Laravel. I was trying to open http://localhost/test/public/ and I got

Error in exception handler.

I googled around and changed the permission of storage directory using chmod -R 777 app/storage but to no avail.

I changed debug=>true in app.php and visited the page and got Error in exception handler:

The stream or file "/var/www/html/test/app/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /var/www/html/test/bootstrap/compiled.php:8423

Then I changed the permissions of storage directory using the command chmod -R 644 app/storage and the 'Error in exception handler' error was gone and a page is loaded. But in there I am getting this:

file_put_contents(/var/www/html/laravel/app/storage/meta/services.json): failed to open stream: Permission denied

Answer

ecairol picture ecairol · Jun 23, 2014

Suggestion from vsmoraes worked for me:

Laravel >= 5.4

php artisan cache:clear 
chmod -R 775 storage/
composer dump-autoload

Laravel < 5.4

php artisan cache:clear 
chmod -R 775 app/storage 
composer dump-autoload

NOTE: DO NOT DO THIS ON ANY REMOTE SERVER (DEV OR PRODUCTION)

When I asked this question, this was a problem on my localhost, running in a Virtual Machine. So I thought setting up a 777 was safe enough, however, folks are right when they say you should look for a different solution. Try 775 first