Install The Web Interface On An Existing Pi-hole

Update 24/04/16 : Please note this guide is now out-dated, and it is recommended that you use the automated install to install and update pi-hole.

If you used the automated install to set up your ad-blocking Pi-hole, it does not install the Web interface (yet) by default.  With a few terminal commands, you can quickly install it for yourself.  The interface is pretty slim at the moment; it provides some stats like:

  • how many ads were blocked today
  • how many DNS queries there were
  • the percentage of traffic that was advertisements
  • the amount of ad domains currently being blocked

There will be more features from the interface as time goes on, but for now it’s a nice interface to quickly see how your Pi-hole is performing.

Please note if you plan on installing this on a model B or B+, performance is painfully sluggish.  This can be improved moderately if you reduce the amount of ad domains being blocked (usually by removing the mahakala list from /usr/local/bin/gravity.sh.  You can also improve performance by truncating the log file (usually via crontab) by running the command sudo truncate /var/log/pihole.log —size 0

How To Install The Interface

Remember, if you used the DietPi image, the Web interface is already installed.  So, assuming you used the automated install command to install the Pi-hole, run the following commands to add the Web interface to your setup:

Install and enable PHP, needed for the interface

sudo apt-get -y install php5-common php5-cgi php5
sudo lighty-enable-mod fastcgi fastcgi-php

Download the interface from my Github repo

sudo wget https://github.com/jacobsalmela/AdminLTE/archive/master.zip -O /var/www/master.zip

Unzip it

if you are running Raspbian “Wheezy” and lighttpd version 1.4.31 or less

sudo unzip /var/www/master.zip -d /var/www/

if you are running Raspbian “Jessie” and <code>lighttpd</code> version 1.4.35+

sudo unzip /var/www/master.zip -d /var/www/html/

Move the files into place

if you are running Raspbian “Wheezy” and lighttpd version 1.4.31 or less

sudo mv /var/www/AdminLTE-master /var/www/admin

if you are running Raspbian “Jessie” and <code>lighttpd</code> version 1.4.35+

sudo mv /var/www/AdminLTE-master /var/www/html/admin

Remove the zip file

sudo rm /var/www/master.zip 2>/dev/null

Make sure that dnsmasq can read the log file

sudo touch /var/log/pihole.log
sudo chmod 644 /var/log/pihole.log
sudo chown dnsmasq:root /var/log/pihole.log

If you do not run the commands above, your interface will show zero for everything except the Domains being blocked.

Modify /etc/lighttpd/lighttpd.conf

Since the Pi-hole, by default (but not for long), redirects all requests it receives to the blank HTML file, you will need to modify /etc/lighttpd/lighttpd.conf to allow the interface to pass through.

Replace these lines:

$HTTP["host"] =~ ".*" {
url.rewrite = (".*" => "pihole/index.html")
}

With this

$HTTP["url"] =~ "^(?!/admin)/.*" {
url.rewrite = (".*" => "pihole/index.html" )
}

This allows anything in the admin folder to be viewable, and sends everything else (advertisements) to the black hole.

Finally, restart the Web server to apply the changes.

sudo service lighttpd restart

You should now be able to access the admin interface (while using the Pi as your DNS server) at http://<IP address of your Pi>/admin/index.php

Troubleshooting

If it is still not working, you may need to try using a different flavor or awkv (such as gawk) if you are using a different operating system.  You may also want to try running the command to see if the fields are in different places.

Your Support Matters

The Pi-hole is free, but is powered by your donations.  I work on it for fun and in my free time, but would like to develop it full time.  I appreciate your donations!




Donate Bitcoins