In my Laravel app, I am using Nginx as the server. Ubuntu version is 21.10
I also want to use Laravel's console (Tinker) to log stuff. When I set www-data
to be the owner of storage
folder, which contains the logs, then I can view my app via localhost
, but then I can't use Tinker to log information, for example Log::debug("test");
, as I get:
UnexpectedValueException with message 'The stream or file
"/var/www/laravel-app/storage/logs/laravel.log" could not be
opened in append mode: Failed to open stream: Permission denied
so I set my user temporarily to own storage
when I want to use Tinker:
sudo chown -R $USER:www-data storage
But then I can't view my app, as I get the same error as above when trying to access localhost
.
How can I make both users have permissions to stoarge
?
sudo gpasswd -a "$USER" www-data
). Why didn't the solution provided by the answer on this post help? You can see below, usingusermod
, I added both users to the group yet that didn't work, but usinggpasswd
and the other lines did help. Why? and do I need to undo theusermod
commands I did? – Ligonsker Apr 09 '22 at 19:44r
/x
permissions for group, which were fixed by thechmod
commands in that answer. Now the answer here also has a permission-fixing command, so it might work now. No, you don't need to undo theusermod
command. – muru Apr 09 '22 at 20:13