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

mengheang's avatar

Laravel Storage Pemission

Hi I have a problem with laravel log error. I log the exception daily

tutorial : https://superuser.com/questions/19318/how-can-i-give-write-access-of-a-folder-to-all-users-in-linux

I use Cron Job in my project. when Cron has any exception, it will create a new log files to storage folder. the same day, if web browser has any exception. it can able to write the error to that existing log file too.

But if the web browser create a log error file first, then Cron can not log any error to that file. it said storage/logs/laravel-2019-10-18.log" could not be opened: failed to open stream: Permission denied

0 likes
9 replies
sopheak's avatar

Hi @mengheang , you should allow permission on Storage folder by using this command "chown -R www-data storage".

Phanna's avatar

Try chown -R www-data:www-data storage/logs

munazzil's avatar

Where do you get the error are you set your .env as follow,

     App_Debug = true;
Phanna's avatar

@mengheang You should share your user for both web server and cron user. First create a user for cron process

useradd cron_user and then login to that cron user for create the cron job. after that

sudo usermod -a -G www-data cron_user

sudo chgrp -R www-data storage/logs

sudo chmod -R g+w storage/logs

Snapey's avatar

run the cron under www-data account. When you create the cron, specify the user

sudo crontab -e -u www-data

(I think thats the correct syntax)

Now both are creating the log file with the same account.

Please or to participate in this conversation.