Laravel – failed to open stream: Permission denied


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/" could not be opened: failed to open stream: Permission denied

I followed the DO tutorial ( and added the following permissions:

sudo chown -R www-data.www-data /var/www/
sudo chown -R www-data.www-data /var/www/

So why is it still throwing the permission denied error?


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/
sudo chgrp -R www-data /var/www/ /var/www/
sudo chmod -R ug+rwx /var/www/ /var/www/

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

Leave a Reply

(*) Required, Your email will not be published