Corbin
3 weeks ago
162
4
Servers

Log file permissions error on AWS elastic beanstalk with Laravel 6:

Posted 3 weeks ago by Corbin

I got the following error when entering my site on a production server:

The stream or file "/var/app/current/storage/logs/laravel-2019-11-22.log" could not be opened: failed to open stream: Permission denied

I ran chmod -R 775 storage/logs/ and composer dump-autoload and I was able to get onto the home page of my site without any errors. After surfing around the site a bit more I was getting the same error in various areas and not in others:

php artisan cache:clear
php artisan config:clear
php artisan config:cache
php artisan optimize:clear
composer dump-autoload

Again same error

The stream or file "/var/app/current/storage/logs/laravel-2019-11-22.log" could not be opened: failed to open stream: Permission denied

I reran my migrations and now I can't access the home page with out the permissions error.

I deleted the following files and ran php artisan cahce:clear:

I then tried to change the owner on the files and set the permissions on the directory and files in the storage:

sudo chown $USER:apache ./storage -R

find ./storage -type d -exec chmod 775 {} \;

find ./storage -type f -exec chmod 664 {} \;

The log files permissions

drwxrwxr-x 2 ec2-user apache 4096 Nov 22 00:44 logs
-rw-rw-r-- 1 ec2-user apache 14544 Nov 22 22:53 laravel-2019-11-22.log

I'm lost. I don't know what is going on, or what to do.

Edit

I tried deleting the files in the logs. Still the same error.

Please sign in or create an account to participate in this conversation.