# Problems running under Apache

**URL:** https://discourse.pi-hole.net/t/problems-running-under-apache/45174
**Category:** Community Help
**Tags:** apache
**Created:** [March 7, 2021, 6:02pm UTC](https://discourse.pi-hole.net/t/problems-running-under-apache/45174 "2021-03-07T18:02:57Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![koboldcommando](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/koboldcommando/32/24111_2.png) [@koboldcommando](https://discourse.pi-hole.net/u/koboldcommando)
#### Post date: [March 7, 2021, 6:02pm UTC](https://discourse.pi-hole.net/t/problems-running-under-apache/45174/1 "2021-03-07T18:02:58Z")

</div>

Hello,

I am trying to run Pi-hole under Apache. I have already worked through the suggestions [here](https://discourse.pi-hole.net/t/migrating-pi-hole-from-lighttpd-to-apache/152), 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:

```auto
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:

```auto
<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](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!

---

<div class="post-metadata">

### Author: ![koboldcommando](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/koboldcommando/32/24111_2.png) [@koboldcommando](https://discourse.pi-hole.net/u/koboldcommando)
#### Post date: [March 7, 2021, 7:14pm UTC](https://discourse.pi-hole.net/t/problems-running-under-apache/45174/2 "2021-03-07T19:14:06Z")

</div>

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

---

<div class="post-metadata">

### Author: ![koboldcommando](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/koboldcommando/32/24111_2.png) [@koboldcommando](https://discourse.pi-hole.net/u/koboldcommando)
#### Post date: [March 7, 2021, 7:16pm UTC](https://discourse.pi-hole.net/t/problems-running-under-apache/45174/3 "2021-03-07T19:16:28Z")

</div>

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

```auto
<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>

```

---

<div class="post-metadata">

### Author: ![system](https://discourse.pi-hole.net/uploads/default/original/3X/7/c/7c8792f649eeb921c5d2b4c41564ffa873d9a2b8.png) [@system](https://discourse.pi-hole.net/u/system)
#### Post date: [March 28, 2021, 7:17pm UTC](https://discourse.pi-hole.net/t/problems-running-under-apache/45174/4 "2021-03-28T19:17:09Z")

</div>

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