Score:0

Restart PHP FPM as root - Authentication is required to restart 'php7.4-fpm.service'

mz flag

I have a www-data user, I allowed to restart PHP FPM by him in /etc/sudoers:

www-data ALL=(ALL) NOPASSWD:/usr/sbin/service php7.4-fpm restart

/etc/sudoers has right permissions

ls -la /etc/sudoers
-r--r----- 1 root root 915 Jan 19 23:26 /etc/sudoers

But I still can't restart FPM from www-data account

/usr/sbin/service php7.4-fpm restart
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to restart 'php7.4-fpm.service'.
Authenticating as: root
Password:

When I'm trying to enter the password, I'm getting different error

polkit-agent-helper-1: pam_authenticate failed: Authentication failure
==== AUTHENTICATION FAILED ===
Failed to restart php7.4-fpm.service: Access denied

What can be wrong?

Score:2
de flag

You need to use sudo in order to make use of sudoers. It looks like you're just running /usr/sbin/service php7.4-fpm restart, try sudo /usr/sbin/service php7.4-fpm restart instead.

mz flag
yes, it was simple, thanks. but it still asks password when I try to restart. sudo /usr/sbin/service php7.4-fpm restart [sudo] password for www-data: how can I get rid of this? as you can see, I have NOPASSWD instruction
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.