skip to Main Content

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


  1. In addition to chmod -R www-data.www-data /var/www/project which sets the group and owner, you might also need to change the specific dir permissions.

    sudo chmod -R 775 /var/www/project/storage/
    sudo chmod -R 775 /var/www/project/bootstrap/cache
    

    If you’re trying to perform operations in your /var/www/project directory on the server, ensure that the user you are logged onto the server as is in the www-data group.

    You can check the groups you’re in simply by typing groups in your shell. If you don’t see www-data in the list returned, add yourself.

    usermod -aG www-data $USER
    

    Once you’ve added yourself to the www-data group you will need to relog for the change to take effect.

    Login or Signup to reply.
  2. 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

    sudo chmod 777 bootstrap/cache/
    sudo chmod 777 storage/logs/*.log
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search