I’ve been trying to set this, but I’m stacked. I don’t know how to set /etc/hosts writable for php, but not for user.
If I set chmod 060 /etc/hosts and chown www-data:www-data /etc/hosts, then php is unable to write (I supposed that php’s group is www-data). If I set chmod 660 /etc/hosts it’s working for php but also for user.
Is this possible?
EDIT:
I found out that my user was in www-data group, so that was why applying 460 on /etc/hosts didn’t work
What you are doing is a terrible idea — the hosts file should never be writable by any user other than root.
Nevertheless, the correct permissions to set to accomplish this would be: