Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

hanif74's avatar
Level 13

Permission problem with Laravel sail

I have a Laravel project that I've installed Laravel Sail on, and I've pushed it to GitHub. I then cloned the project onto my production server and ran the command "docker run --rm -v $(pwd):/app composer install" to install all the necessary dependencies. After that, I ran "vendor/bin/sail up -d" to start the containers.

However, when I try to access the project by browsing to the IP or URL, I get an error that says "The stream or file "/var/www/html/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied". I've tried to fix this by running "chmod -R 777 storage", but then I get an error that says "No application encryption key has been specified." When I try to generate a key using the command "sail artisan key:generate", I get an error that says "file_put_contents(/var/www/html/.env): Failed to open stream: Permission denied".

It seems like I'm facing permission issues with my Laravel project on the production server, and I'm not sure how to resolve them.

I have done all steps as root user in my production server.

0 likes
2 replies
LaryAI's avatar
Level 58

The issue seems to be related to file permissions. You can try running the following commands to fix the issue:

sudo chown -R $USER:$USER .
sudo chmod -R 755 storage
sudo chmod -R 755 bootstrap/cache

The first command changes the ownership of the project directory to the current user. The second and third commands set the appropriate permissions for the storage and bootstrap/cache directories.

After running these commands, try generating the encryption key again using the command sail artisan key:generate. This should resolve the permission issues and allow you to access the project.

hanif74's avatar
Level 13

I did it. But it didn't solve my problem.

Please or to participate in this conversation.