Migrating Pi-Hole from lighttpd to apache


Is this possible? I could have SWORN I saw it done here on the forums, but now that I search it, I cannot find it at all.

I’ve googled it, but only found:

which mentions to downgrade PH. But I rather not do that.

My end goal is to also turn my RaspPi into a webserver, but I am mainly familiar with Apache and even Nginx. Also, some services I am wanting to reverse proxy into, I have instructions for Apache, but nothing for lighttpd. So the smallest change (I think) is to move PH from lighttpd to apache, rather than move all the services to lighttpd, etc.

School Management

I am running the apache webserver instead of lighttpd on the pi3 with xbian installed. So yes it is possible to migrate using another webserver.
I did not encounter problems with the functionality of the pi-hole gui.

Only downside is, that if you upgrade pi-hole using the update script, it will automatically install lighttpd.
So after upgrading I run:
sudo apt-get remove lighttpd
to uninstall lighttpd.


Is it possible to post your steps into setting the admin dashboard on Apache?


It has been a long time ago since I installed Apache, but the thing is that I already installed it on the Pi before installing pi-hole. I remember that installing Apache was just a standard default install.

  • sudo apt-get install apache2
    I also installed php5 (but only needed if you use php in webpages)
  • sudo apt-get install php5
    Apache uses /var/www/html as default location for your webpages.
    Since pi-hole gets installed in the same directory (in sub-directory pihole), there is nothing extra to be done to use the apache server except from starting it: sudo service apache2 starrt

In the webbrowser I request webpage:
or you can use the pi ip-address instead of ‘xbian’ in the URL.


would be a nice feature for the install script where you could select lighttpd or apache i am not sure if thats possible since there is a lighttpd.conf for the pi-hole /etc/lighttpd/lighttpd.conf. but i am sure it has been already discussed just have to look around the internet.


what is the vhost setup though? iirc (haven’t looked at it recently), but it had a setup for the admin, and then another for handling of the DNS queries.


We actually had a pull request a whole back to address this, which ice asked the developer to take another look at to update it. Never say never


have you been looking for this?


well its still a bit hell of work and requires many tests. i am looking forward to it.


I know there are people who have switched to Apache. You could try looking at the DietPi fork (not maintained by the Pi-hole team) as that uses Apache. It might help give you some clues.

We are working to develop Pi-hole so it can be used with your choice of Web server and/or resolver.


Awesome! I hope you will add NGINX support too. Also I am looking for some info on how to host a website side-by-side with pi-hole. As far as I know it is not possible to host any site on localhost:80 when using pi-hole, or am I wrong? I guess it would be possible to user port 443 for other sites.


You can use lighttpd on a different port and it will play nice.


Thanks, it works great! I wrote a little script to change the port:


if (whiptail --title "Change Pi-hole port" --yesno "Do you want to change the port pi-hole uses?" 8 78) then
  PORT_PIHOLE=$(whiptail --inputbox "Which port you do you want to use for Pi-hole?" 8 78 $PORT_PIHOLE --title "Pi-hole Port" 3>&1 1>&2 2>&3)
  sed -i "s/server.port                 = 80/server.port                 = $PORT_PIHOLE/" /etc/lighttpd/lighttpd.conf
  service lighttpd restart


I just installed pihole on ubuntu server and because I already use Apache & PHP I uninstalled lighttpd.
I have several virtual sites on Apache so I added also pihole; all work without problems.

Here it is my config if anybody need to replicate for his use:
edit: /etc/apache2/sites-available/000-default.conf

#=== pihole WEBSITE ===

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName pihole
        ServerAlias pi.hole

        DocumentRoot /var/www/html/dns
        <Directory /var/www/html/dns/>
                Options FollowSymLinks MultiViews
                AllowOverride all
                Order deny,allow
                allow from all

        ErrorLog ${APACHE_LOG_DIR}/pihole_error.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/pihole_access.log combined

#=== site1 WEBSITE ===

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName site1

        DocumentRoot /var/www/html/site1
        <Directory /var/www/html/site1/>
                Options FollowSymLinks MultiViews
                AllowOverride all
                Order deny,allow
                Deny from all
                allow from
                allow from

        ErrorLog ${APACHE_LOG_DIR}/site1_error.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/site1_access.log combined

#==== site2 WEBSITE ====

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName webtv

        DocumentRoot /var/www/html/site2
        <Directory /var/www/html/site2/>
                Options FollowSymLinks MultiViews
                AllowOverride all
                Order deny,allow
                Deny from all
                allow from
                allow from

        ErrorLog ${APACHE_LOG_DIR}/site2_error.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/site2_access.log combined


edit your server hosts file so you can access any website you need from server,
( if you host your custom files for blocking):

/etc/hosts       localhost       ubuntu1       pihole       site1       site2 site1 site2 pihole ubuntu1

copy all web files for pihole ( move it from /var/www/html/ ) and also content from pihole in dns:
it will look like this:


If I did not forgot something this is all you need to change to have pihole working in Apache, so now reload/restart apache.

Pages are still blocked after uninstall

To add to @speedyq post, one also needs to install package ‘libapache2-mod-php5’ to get php to work with apache:
sudo apt-get libapache2-mod-php5


In Apache 2.4 and later, one should replace

Order deny,allow
allow from all


Require all granted

Otherwise an error will be thrown.


where can I change this script?


how to overwrite the file?


It will show this error


You need to launch the editor with sudo.

Something like sudo gedit or what ever your editor is. Looks like Leafpad possibly.

If this is something that needs to be fixed for your project, just change the lighttpd listening port. You will not see the blocking page and you will have to change the address for the admin page to that chosen port but it will still use the DNS blocking.


I dont know what is the command actually, is it true?

I cant edit 000-default.conf file

pi@raspberrypi:/etc/apache2/sites-available $ cd 000-default.conf
-bash: cd: 000-default.conf: Not a directory
pi@raspberrypi:/etc/apache2/sites-available $