Issue
I’m trying to install a laravel app on digital ocean. When I run the command php artisan migrate --seed
I’m getting the following error when it reaches one of the seeders:
The stream or file "/var/www/test.mysite.com/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied
I followed the DO tutorial (https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-laravel-with-nginx-on-ubuntu-20-04) and added the following permissions:
sudo chown -R www-data.www-data /var/www/test.mysite.com/storage
sudo chown -R www-data.www-data /var/www/test.mysite.com/bootstrap/cache
So why is it still throwing the permission denied error?
Solution
Managed to fix. I needed to give my self (the logged in ssh user) ownership of the directory and the webser as follows:
sudo chown -R $USER:$USER /var/www/test.mysite.com
sudo chgrp -R www-data /var/www/test.mysite.com/storage /var/www/test.mysite.com/bootstrap/cache
sudo chmod -R ug+rwx /var/www/test.mysite.com/storage /var/www/test.mysite.com/bootstrap/cache
Answered By – adam78
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0