Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I got message for error_log file "The stream or file ".../laravel.log" could not be opened: failed to open stream: Permission denied" [duplicate]

Tags:

laravel

Tue Jun 20 13:17:41.195156 2017] [:error] [pid 14454] [client 203.131.216.144:60475]

PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/var/www/html/app/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied' in

/var/www/html/app/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107\nStack trace:\n#0

/var/www/html/app/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\Handler\StreamHandler->write(Array)\n#1

/var/www/html/app/vendor/monolog/monolog/src/Monolog/Logger.php(336): Monolog\Handler\AbstractProcessingHandler->handle(Array)\n#2

/var/www/html/app/vendor/monolog/monolog/src/Monolog/Logger.php(615): Monolog\Logger->addRecord(400, Object(Symfony\Component\Debug\Exception\FatalErrorException), Array)\n#3

/var/www/html/app/vendor/laravel/framework/src/Illuminate/Log/Writer.php(202): Monolog\Logger->error(Object(Symfony\Component\Debug\Exception\FatalErrorException), Array)\n#4

/var/www/html/app/vendor/laravel/framework/src/Illuminate/Log/Writer.php(113): Illuminate\Log\Writer->writeLog('er in

/var/www/html/app/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 107, referer: http://203.131.209.179/app/login

like image 732
Sangwondee Avatar asked Jun 21 '17 06:06

Sangwondee


People also ask

Can't be opened in append mode failed to open stream permission den?

If you encountered an error that says “Could Not Be Opened In Append Mode: Failed To Open Stream: Permission Denied” such us the the image below, you can solve this by simply changing the permission access of certain file. The chmod 666 will allow all users to read and write but cannot execute the file.

What is error log in Laravel?

The Laravel logging facilities provide a simple layer on top of the powerful Monolog library. By default, Laravel is configured to create a single log file for your application, and this file is stored in app/storage/logs/laravel.

How do I view Laravel logs?

You can see the generated log entries in storage/logs/laravel. log file.

Can I delete Laravel log?

If you're having a space problem you can try using daily logs, it will automatically keep last X days of log (default 5). You can see it in Errors & Logging - Log Storage. Otherwise you can simply remove the storage/logs/laravel. log file or make a command to do so (like php artisane log:clear ).


2 Answers

Directory Permissions

After installing Laravel, you may need to configure some permissions. Directories within the storage and the bootstrap/cache directories should be writable by your web server or Laravel will not run.

https://laravel.com/docs/5.4/installation#installing-laravel

So, for example, in Linux you can do this by executing chmod command:

chmod -R 755 storage bootstrap/cache
like image 107
Alexey Mezenin Avatar answered Nov 02 '22 22:11

Alexey Mezenin


In your project directory run this command:

chmod -R 777 storage bootstrap/cache

like image 35
Motiur Rahaman Avatar answered Nov 03 '22 00:11

Motiur Rahaman