refactorian / laravel-docker

Laravel Docker Template - Laravel v11.x, PHP v8.3.x, MySQL v8.1.x, phpMyAdmin v5.x, Mailpit v1.x
286 stars 117 forks source link

The stream or file "/var/www/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied #84

Closed devmansurov closed 5 months ago

devmansurov commented 5 months ago

When I run all these commands:

git clone https://github.com/refactorian/laravel-docker.git
cd laravel-docker
docker compose up -d --build
docker compose exec php bash
composer setup

And open the application itself in the browser I get this error:

The stream or file "/var/www/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied

Link to shared error

When I added the storage folder to the php service then I received this error:

    php:
        build: .docker/php
        ports:
            - 5173:5173
        volumes:
            - .:/var/www:cached
            - .:/var/www/storage

Then get this error:

There is no existing directory at "/var/www/storage/logs" and it could not be created: Permission denied

refactorian commented 5 months ago

@devmansurov Hi 👋 are you using Windows? Try these steps :

docker compose up -d --build
docker compose exec php chmod -R 775 storage bootstrap/cache
docker compose exec php bash
composer setup
devmansurov commented 5 months ago

docker compose exec php bash

Hi. I use Ubuntu. I tried all the commands according to your instructions but same error:

The stream or file "/var/www/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied

Note: Also docker buld cache was been cleared before running your commands using this command: docker builder prune -f

refactorian commented 5 months ago

@devmansurov Try this:

docker compose exec php bash
chown -R www-data:www-data /var/www/storage /var/www/bootstrap/cache
chmod -R 775 /var/www/storage /var/www/bootstrap/cache

Please let me know if the problem was solved, I'll try to improve the environment.

devmansurov commented 5 months ago

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

Thanks, works like a swiss watch!

devmansurov commented 5 months ago

But I have also Permission denied error with phpMyAdmin:

image

refactorian commented 5 months ago

@devmansurov Try this:

docker compose exec phpmyadmin chmod 777 /sessions