'Laravel 5 permission denied when writing in log file
I have Ubuntu and Laravel 5 framework and I see the white screen in the browser.
When I change storage/logs directory permissions it helps, but I have to do it every day, due the 'daily' log configuration.
Solution 1:[1]
The permissions for the storage and vendor folders should stay at 775, for obvious security reasons.
However, both your computer and your server Apache need to be able to write in these folders. Ex: when you run commands like php artisan, your computer needs to write in the logs file in storage.
All you need to do is to give ownership of the folders to Apache :
sudo chown www-data:www-data /path/to/your/project/vendor
sudo chown www-data:www-data /path/to/your/project/storage
Then you need to add your computer (referenced by it's username) to the group to which the server Apache belongs. Like so :
sudo usermod -a -G www-data userName
Most frequently, groupName is www-data but you might want to replace it with your correct group.
Solution 2:[2]
I got the same error. By using the following command I could solve it. For some reason, it is not about the log file.
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
Solution 3:[3]
- chmod 777 is in general a security risk extremely risky.
chmod 775 for the storage folder is fine considering user also
belongs to web server group.with -R its extremely risky since for files an execute permissions is not at all required.
chmod 664 for files inside storage. chmod 775 for folders inside
Solution 4:[4]
In config/login.php, check permissions are set:
'daily' => [
'driver' => 'daily',
'path' => storage_path('logs/laravel.log'),
'level' => 'debug',
'days' => 14,
'permission' => octdec('0666'),
],
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | BassMHL |
| Solution 2 | Isuru |
| Solution 3 | Yogesh Kamat |
| Solution 4 | alexeydemin |
