Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 739
alexeydemin Avatar asked May 21 '15 00:05

alexeydemin


People also ask

How do I give permission to storage in laravel?

Change all file permissions to 644. Change all folder permissions to 755. For storage and bootstrap cache (special folders used by laravel for creating and executing files, not available from outside) set permission to 777, for anything inside.

Where is the laravel log file?

By default, Laravel is configured to create a single log file for your application, and this file is stored in app/storage/logs/laravel. log .

Could not be opened in append mode failed to open stream Permission denied the?

Log" Could Not Be Opened In Append Mode: Failed To Open Stream: Permission Denied problem can be solved using the computer language. Another approach, which includes several samples of code, can be utilised to resolve the identical problem The Stream Or File /Storage/Logs/Laravel.


2 Answers

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.

like image 154
BassMHL Avatar answered Oct 20 '22 08:10

BassMHL


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
like image 8
Isuru Avatar answered Oct 20 '22 10:10

Isuru