Problems running under Apache

Hello,

I am trying to run Pi-hole under Apache. I have already worked through the suggestions here, but am still experiencing issues with the web GUI.

I am running Pi-hole v5.2.4 on CentOS 8.3, with Apache v2.4 and PHP v7.2.

Mostly, it appears to be working, but if I attempt to make any changes via the web GUI, nothing gets committed, and the OS's 'root' user receives the following mail:

server-1.my.lan : Mar  7 17:54:09 : apache : user NOT in sudoers ; TTY=unknown ; PWD=/var/www/html/admin ; USER=root ; COMMAND=/usr/local/bin/pihole status web

Web files are here: /var/www/html/admin and here: /var/www/html/pihole
All files are owned by apache:apache.

Apache's conf file looks like this:

<VirtualHost *:80>
    ServerName server-1.my.lan

    DocumentRoot /var/www/html/admin
    <Directory /var/www/html/admin/>
        Options FollowSymLinks MultiViews
        AllowOverride all
        Require all granted
    </Directory>

    ErrorLog /var/log/httpd/pihole_error.log
    LogLevel warn
    CustomLog /var/log/httpd/pihole_access.log combined
</VirtualHost>

Debug Token: https://tricorder.pi-hole.net/7ef0vwuht3

As it's a huge security hole to simply grant 'apache' SUDO access, I am assuming there is something else I need to do to fix this issue?

Any suggestions would be very much appreciated.

Thank you!

I have decided to add the following to a /etc/sudoers.d/my file:
apache ALL = NOPASSWD: /usr/local/bin/pihole

This appears to have fixed the issue with 'apache' not being allowed to run the pihole application.

How can I test my Pi-hole system now, to be sure it's working properly?

Thanks

I have also revised my apache virtualhost conf file to be this:

<VirtualHost *:80>
    Define vDOMAIN pi-hole.my.lan
    ServerName ${vDOMAIN}

    DocumentRoot /var/www/html

    ErrorDocument 404 /pihole/index.php

    <Directory /var/www/html/admin/>
        Options FollowSymLinks MultiViews
        AllowOverride all
        Require all granted
    </Directory>

    ErrorLog /var/log/httpd/${vDOMAIN}/pihole_error.log
    LogLevel warn
    CustomLog /var/log/httpd/${vDOMAIN}/pihole_access.log combined
</VirtualHost>

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.