Skip to content

Did you know?

Set the setgid bit on storage/logs so Laravel log files created by cron stay writable by the web server.

chmod 2775 storage/logs (group www-data) plus permission 0664 in config/logging.php.

Explained

A classic Laravel error, “laravel.log could not be opened in append mode: Permission denied”, appears when php artisan or a cron job running as your deploy user creates the day’s log file, and PHP-FPM (www-data) then can’t write to it.

Make new files in the folder inherit the web server’s group:

sudo chgrp www-data storage/logs
sudo chmod 2775 storage/logs

Then add 'permission' => 0664 to the single and daily channels in config/logging.php. In our test on Laravel 13, files created by either user came out as -rw-rw-r-- deploy www-data and both could log. 0664 on its own is not enough: without the setgid bit, the file gets the deploy user’s group.

Learn more

← All tech tips · Suggest a fix

Back to top