Installing Pi-hole on Existing Apache Server

I am working from a NextCloud install first then installing PiHole afterwards. I had trouble allowing the correct access via different port than 80. I chose 81.

  1. Added it to new pihole.conf in the /etc/apache2/sites-available

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/pihole.conf

sudo nano /etc/apache2/sites-available/pihole.conf
added or edited the following lines:
<VirtualHost *:81>
DocumentRoot /var/www/html/admin/
<Directory /var/www/html/admin/>

  1. Added a new Listen port in the port.conf

sudo nano /var/apache2/ports.conf
add line:
Listen 81

  1. Whitelisted the directories for pihole specifically in the apache2.conf

sudo nano /var/apache2/ports.conf
add lines at the appropriate spot:
<Directory /var/www/html/pihole/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted

	<Directory /var/www/html/admin/>
        Options Indexes FollowSymLinks
        AllowOverride None
	    Require all granted
	</Directory>
  1. Finally update the Apache2 config files & restart service

sudo a2ensite pihole
sudo systemctl reload apache2

Not sure if that was all overkill or I opened it up too much but that I how I got it working on my R-Pi 4.
Documenting it to help out anyone else who was a NOOB like me…

1 Like