Pi-hole Admin not saving changes when using Apache

I moved over to use Apache instead of Lighttpd. Everything seems to work fine, however, whenever I try and save anything in the admin, nothing saves. As the page reloads, it takes a lot longer than it should. When the page loads after 5-7 seconds, a success message shows up, but the settings/entries remain unchanged. While troubleshooting, I installed Lighttpd on port 8080, and Pi-hole admin functions as it should. I've done quite a bit of research on this, and I've tried everything suggested, with no difference. Some articles I've read are:

I've made sure all the PHP modules are installed. I've made sure that the Apache user (apache in Fedora) is in the pihole group. I've tried the suggestion under the Arch Wiki (section 2.2.2.2) in hopes that it would apply to Fedora, but it did not.

Does anybody know what else could be causing this? I suspect it's some permissions issue, possibly with PHP, but I've exhausted everything I know how to do.

Server Information

  • OS: Fedora Server 39

What I have changed since installing Pi-hole:

  • Moved to Apache webserver
  • Added apache user to pihole group
  • Tried adjusting open_basedir directories
  • Made sure /var/www/html/* is owned by apache user.

I'm not sure if I can help because I never used Pi-hole with Apache, but I think you can find some answers looking at the apache2 logs. Do you see PHP errors, permission errors, nothing?

Unfortunately, I can't see anything in the logs that indicate something is wrong. It all seems to be normal access logs for GETs and POSTs, most of which are returning 200s, with an occasional 300-class code.

Digging a bit more, I found three entries in /var/log/php-fmp/www-error.log when I try and save something:

[18-Apr-2024 19:29:50 UTC] PHP Warning: Executing sudo pihole -a -i bind -web failed. in /var/www/html/admin/scripts/pi-hole/php/func.php on line 173 [18-Apr-2024 19:29:52 UTC] PHP Warning: Executing sudo pihole -a ratelimit 1000 60 false failed. in /var/www/html/admin/scripts/pi-hole/php/func.php on line 173 [18-Apr-2024 19:29:54 UTC] PHP Warning: Executing sudo pihole -a setdns "9.9.9.9,149.112.112.112" domain-not-needed no-bogus-priv dnssec rev-server 10.0.0.0/8 10.1.0.1 failed. in /var/www/html/admin/scripts/pi-hole/php/func.php on line 173

Again, Lighttpd works, so what is causing Apache to not be able to execute these commands? Is there some kind of permissions that Apache needs that Lighttpd automatically assigns?

This is definitely an Apache config issue, but I have no idea what it is exactly.

Take a peak at /etc/sudoers.d/pihole file, it will usually be setup to allow www-data user to execute pihole script, I guess you could just duplicate that entry using apache user.

1 Like

That was it! You, sir, deserve all the gold stars. Thank you!

For reference for others and my future self, the solution was two-fold:

  1. Make sure that the Apache user (www-data or, in Fedora's case, apache), has pihole group access, found in /etc/group.
  2. Make sure that the Apache user has pihole sudo permissions, found in /etc/sudoers.d/pihole.