Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

tnort's avatar
Level 4

Laravel storage permission issues

Hi,

I need some help to sort out the permissions issue I get with the logger.

I set my Laravel logger to basically create each day a new log file which is located in storage/logs. Every day, the application creates a new log file laravel-date.log.

The application itself is owned by the user I am using to deploy the application and the group is www-data. I also added the user to the www-data group.

My issue is that when new log files are created (daily) it is owned by the www-data user with only read permissions for the group users.

-rw-r--r-- 1 www-data www-data 1306 Aug 2 07:00 laravel-2024-08-02.log

This results in an error everyday as I have a task, that runs daily and dispatches a job which gets pushed in the database queue. When the queue job is executed by a supervisor, I get a permission error and fails to complete:

+"exception": """
          UnexpectedValueException: The stream or file "/var/www/html/storage/logs/laravel-2024-08-02.log" could not be opened in append mode: Failed to open stream: Permission denied\n
The exception occurred while attempting to log: something went wrong when processing the admission test reminder job in /var/www/html/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:146\n

How can I address this issue?

0 likes
1 reply
Snapey's avatar

in the logfile config you can set the default permission. Sorry, can't recall the specifics

1 like

Please or to participate in this conversation.