1
votes

I have a Laravel 5 project deployed by Zend Server, and everything seemed to be working fine until I got an error in my code, which caused the the framework to need to write to the log file. At that point ZRay shows me this error

Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/usr/local/zend/var/apps/http/vtribes.local/80/2.1_33/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied' in /usr/local/zend/var/apps/http/vtribes.local/80/2.1_33/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:97 Stack trace: #0 /usr/local/zend/var/apps/http/vtribes.local/80/2.1_33/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\Handler\StreamHandler->write(Array) #1 /usr/local/zend/var/apps/http/vtribes.local/80/2.1_33/vendor/monolog/monolog/src/Monolog/Logger.php(336): Monolog\Handler\AbstractProcessingHandler->handle(Array) #2 /usr/local/zend/var/apps/http/vtribes.local/80/2.1_33/vendor/monolog/monolog/src/Monolog/Logger.php(615): Monolog\Logger->addRecord(400, Object(UnexpectedValueException), Array) #3 /usr/local/zend/var/apps/http/vtribes.local/80/2.1_33/vendor/laravel/framework/src/Illuminate/Log/Writer.php(202): Monolog\Logger->error(Object(UnexpectedValueException), Array) #4 /usr/local/zend/var/apps/http/vtribes.local/80/2.1_33/vendor/laravel/framework/src/Illuminate/Log/Writer.php(113): Illuminate\Log\Writer->writeLog('error', Object(UnexpectedValueException), Array) #5 /usr/local/zend/var/apps/http/vtribes.local/80/2.1_33/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(56): Illuminate\Log\Writer->error(Object(UnexpectedValueException)) #6 /usr/local/zend/var/apps/http/vtribes.local/80/2.1_33/app/Exceptions/Handler.php(36): Illuminate\Foundation\Exceptions\Handler->report(Object(UnexpectedValueException)) #7 /usr/local/zend/var/apps/http/vtribes.local/80/2.1_33/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(79): App\Exceptions\Handler->report(Object(UnexpectedValueException)) #8 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(UnexpectedValueException)) #9 {main} thrown

The problem here is that the file

/usr/local/zend/var/apps/http/vtribes.local/80/2.1_33/storage/logs/laravel.log

is not only owned by me, the group is zend and the file permission is 777. I have tried all user/group/mode permissions on this file, but ZRay still shows the same error. I even deleted the file and then touched it.

-rwxrwxrwx. 1 paul zend 0 May 24 00:17 /usr/local/zend/var/apps/http/vtribes.local/80/2.1_33/storage/logs/laravel.log

Any thoughts on where else to look for a possible culprit?

Thanks, Paul

3

3 Answers

1
votes

Check this answer. To access file, you must have execute permission on all parent directories. In your case

  • /usr
  • /usr/local
  • /usr/local/zend

and so on...

Seems like you have correct permissions on application folder, but something is wrong with storage/logs. Check execute permission on this directories.

1
votes

The log file should be owned by the same user as zend service is running. Typically this is "nobody" or "apache"

While your file hints at it being owned by its own user, I would first check to see what your web server is running I would run a ps -ef | grep | more

typically its httpd (for CentOS / RHEL) or apache2 for ubuntu

ps -ef | grep httpd | more

0
votes

I figured out the permissions late last night, and if done manually I can get the site to work after a deploy. This then leads me to another question here

FYI: The execute permission was set on the entire path parts, but the link was a good read anyway, so thanks Andrew