Score:0

How to avoid using sudo for newly created files and folders by www-data?

fr flag

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?

in flag
Is the Apache user required? If the permissions should always be for a user account, perhaps the Apache configuration can be changed to run as that particular user.
Foobarer avatar
fr flag
Btw it's nginx, maybe I could try to find a way to do that
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.