Install Pi-hole with existing Apache2 on Raspberry Pi 4

This is a record of the steps that I took to install pi-hole on my raspberry pi (RPi). It might not be universally applicable. Still hopefully it can help some out there.

Precondition
  • apache2 and php already installed and set up on your raspberry pi (raspbian)

 Download and run the automated install (Reference)

Run this command in the terminal:

curl -sSL https://install.pi-hole.net | bash
  1. Select interface: wlan0 (depending on your need, wlan0 is for wifi and eth0 is for the wired connection)
  2. Select DNS provider: OpenDNS
  3. IPv4&v6: both
  4. Use static IP?: Yes
  5. Web admin interface: yes
  6. Install web server?: No
  7. Log query: On
  8. Privacy: full

After these steps, a message will appear in the terminal telling you the IP and the password of the admin page (something like http://192.168.x.xxx). Note this down as you will need it later.

Two warnings

The installation finished with two warnings:

  1. xxx modules are missing for php
  2. the web server user needs to be member of the “pihole” group for full functionality

The first can be solved using sudo apt install php-xxx to install these packages.

The second can be solved by sudo usermod -a -G pihole your_apache2_user.

Some setup on the admin page

On the left, go to group management -> Adlists to add custom list. Below are some that I use:

After adding your lists, go to tools -> update gravity -> update.

Check it’s working

Go to a site that you are certain that is riddled with ads or a ab backer checker site (such as this one), and you show see that most of the ads are gone!

Now, enjoy a more pleasant online experience!