Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
563 views
in Technique[技术] by (71.8m points)

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

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

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...