I am deploying a project to Ubuntu on Digital Ocean, using these
instructions.
I am running into permissions issues whereby if I give these permissions
sudo chown -R www-data.www-data /var/www/project/storage sudo chown -R www-data.www-data /var/www/project/bootstrap/cache
I get access to my login page (though a 500 error on every other route), but I also get The stream or file "/var/www/project/storage/logs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied
whenever I try to run php artisan optimize, route:clear, etc.
If I set the permissions to this
sudo chown -R $USER /var/www/project/storage sudo chown -R $USER /var/www/project/bootstrap/cache
I get the opposite problem, wherein I can run artisan commands and write to the log, but no pages are accessible.
Any help would be appreciated
2
Answers
In addition to
chmod -R www-data.www-data /var/www/project
which sets thegroup
andowner
, you might also need to change the specificdir
permissions.If you’re trying to perform operations in your
/var/www/project
directory on the server, ensure that theuser
you are logged onto the server as is in thewww-data
group.You can check the groups you’re in simply by typing
groups
in your shell. If you don’t seewww-data
in the list returned, add yourself.Once you’ve added yourself to the
www-data
group you will need to relog for the change to take effect.You need to change boostrap cache folder and laravel.log file into read, write, and execute. Go to your laravel project, and put this code