Lumen: failed to open stream: Permission denied in .../vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107

zwitterion picture zwitterion · Oct 9, 2017 · Viewed 12k times · Source

My OS is ubuntu 16.04 and I am running Lumen 5.5. When I try to run the app in the browser I get an error 500:enter image description here

and I am getting that error in my /var/log/nginx:

2017/10/09 06:51:26 [error] 1063#1063: *132 FastCGI sent in stderr: 
"PHP message: PHP Fatal error:  Uncaught UnexpectedValueException: 
 The stream or file "/home/ila/vhosts/dref_api.com/storage/logs/lumen.log"
 could not be opened: failed to open stream: Permission denied in 
 home/ila/vhosts/dref_api.com/
 vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107

Permission in storage/ is :enter image description here

Permissions in vendor/ and all monolog/ sub files are :enter image description here

So, I think could apply sudo chmod -R guo+w /vendor but I dont know if it would works or even if it is a good practice.

How are you solving this issue?

Answer

iCoders picture iCoders · Oct 9, 2017

It looks like Storage folder doesnt have permission to write log files so you can run

    chmod -R o+w projectname/storage
   chmod -R o+w projectname/bootstrap

if you are using nginx then you need to use nginx user permission like below

sudo chown -R nginx:root storage
sudo chown -R nginx:root bootstrap