The stream or file "/app/storage/logs/laravel.log" could not be opened: failed to open stream:Permission denied

Viewed 7582

While I work locally, everything works fine. But when I deploy on Google Cloud I have this error

The stream or file "/app/storage/logs/laravel.log" could not be opened: failed to open stream:Permission denied

I have tried to run this from my terminal. I am using window PC and Vscode

chmod -R 775 storage

chmod -R 775 bootstrap/cache

When I run this, it returns

chmod is not recognized as internal or external commands, operable program or batch file.

I also tried this method

"post-install-cmd": [
            "chmod -R 775 storage",
            "chmod -R 775 bootstrap/cache",
            "php artisan optimize:clear"
]

I don't know how to solve this. I need help

3 Answers

just run this first command

php artisan config:cache

php artisan clear:cache

php artisan route:clear

php artisan view:clear

It's usually because your project folder owner is different than your web server's default owner

I don't know which web server you are using but the common web servers are apache and nginx

For apache and nginx it's usually is www-data so if you are using apache or nginx
sudo chown -R www-data:www-data /path/to/your/project/folder

otherwise you should figure out what is your web server default ownership is.

Edit:

Please note that giving 777 permission is a bad practice and it cause security issues. there is nothing wrong with default permissions of file and folders of laravel.

Related