-5

Try to look for a solid answer, but nothing yet. My current setup is as follow:

  • local ubuntu server
  • docker
  • laravel application

When the ownership of storage/ and bootstrap/ are set to www-data:www-data (chown) the app is working well. The only issue I have is when I try to run composer or artisan commands it will give me an error:

Generating optimized autoload files Illuminate\Foundation\ComposerScripts::postAutoloadDump @php artisan package:discover --ansi UnexpectedValueException The stream or file "/home/amplr/portal.amplr.be/storage/logs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied

When I set the ownership back to the ubuntu user, composer and artisan work, but the app throws the permission error. I have to chown back to www-data:www-data after i finished my composer commands.

What am I doing wrong?

  • u need to give permission to `/home/amplr/portal.amplr.be/storage` folder `sudo chmod -R 777 /home/amplr/portal.amplr.be/storage` – Kamlesh Paul Aug 25 '20 at 08:52
  • 1
    Does this answer your question? [Laravel daily log created with wrong permissions](https://stackoverflow.com/questions/27674597/laravel-daily-log-created-with-wrong-permissions) – Spholt Aug 25 '20 at 09:33

2 Answers2

4

I would use

sudo chown -R $USER:www-data storage
sudo chown -R $USER:www-data bootstrap/cache

together with

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

So you got read/write/execute for your linux user and also for apache via the www-data group.

Flo Espen
  • 450
  • 4
  • 10
0

This may have already been answered in this post.

Laravel daily log created with wrong permissions

In essence, there are two different users at work here:

  1. Your PHP FPM user will be www-data:www-data. This user will have permissions to write to the log files, which is why this is currently working for you.

  2. You PHP CLI user will be whichever user you are logged in as. This user sounds like it doesn't have access to write to the log files.

There are a number of solutions to this, from opening up all of the permissions (bad idea) to creating new log files for both the FPM and CLI users.

Spholt
  • 3,724
  • 1
  • 18
  • 29