I've been using the following post for some time to avoid using sudo
:
How to avoid using sudo when working in /var/www?
But when I use Laravel to create folders, it's created under group www-data
and user www-data
, and then I have to perform all the commands in the post all over, i.e.:
sudo gpasswd -a "$USER" www-data
sudo chown -R "$USER":www-data /var/www
find /var/www -type f -exec chmod 0660 {} \;
sudo find /var/www -type d -exec chmod 2770 {} \;
It's annoying because the code I'm working on creates many new folders and files.
The server (via the Laravel code) creates folders with the following permissions:
drwx--S--- 2 www-data www-data
and files with the following permissions:
-rw-r--r-- 1 www-data www-data
In this case, how can I avoid using sudo?