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
</Directory>
ErrorLog ${APACHE_LOG_DIR}/pihole_error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/pihole_access.log combined
</VirtualHost>
#=== 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 127.0.0.1
allow from 10.22.22.0/24
</Directory>
ErrorLog ${APACHE_LOG_DIR}/site1_error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/site1_access.log combined
</VirtualHost>
#==== 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 10.22.22.0/24
allow from 127.0.0.1
</Directory>
ErrorLog ${APACHE_LOG_DIR}/site2_error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/site2_access.log combined
</VirtualHost>
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
127.0.0.1 localhost
127.0.1.1 ubuntu1
127.0.1.2 pihole
127.0.1.3 site1
127.0.1.4 site2
10.22.22.16 site1
10.22.22.16 site2
10.22.22.16 pihole
10.22.22.16 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:
/var/www/html/dns/admin/...
/var/www/html/dns/pihole/...
/var/www/html/dns/blockingpage.css
/var/www/html/dns/index.js
/var/www/html/dns/index.php
/var/www/html/site1/...
/var/www/html/site2/...
If I did not forgot something this is all you need to change to have pihole working in Apache, so now reload/restart apache.