Build a Pihole DNS Server using Apache2 on Ubuntu 22.04.1LTS

Following on from my article on building a Pihole DNS server using Ubuntu Server and Apache2 webserver instead of the default Lighttpd webserver, I’ve now put together this updated article on how to do the same but on Ubuntu Server 22.04.1LTS.

With Ubuntu Server 22.04.1LTS there have been a number of changes and support for various things removed. This they say is progress but, to me it feels like a step backwards.

For example the new installer is incredibly slow compared to the old one, it lacks the functionality of the old installer and has far less capability.

Anyway, let’s crack on with the build as it’s still possible, we just have to work around a few things to get it working.

So, first off install Ubuntu Server 22.04.1LTS as a base build. Make sure you select to install the OpenSSH-Server package during the installation process.

Once your server O/S is installed and has been configured with a static IP Address you are ready to begin the Pihole installation process.

SSH into your server and run the following commands:

Note: You need to become the root user to execute these commands. You can do it via sudo as shown below or by just using su – if you’ve already set a password for the root user.

sudo su -

apt install net-tools tasksel

tasksel install web-server

apt install php-sqlite3 php8.1-sqlite3 sqlite3 libaprutil1-dbd-sqlite3

It’s important that the commands are run in the order shown above!

Once all these commands have run without error reboot your server.


Once the system comes back up check the webserver is working OK by pointing your web browser at the IP address of your server, you should see the standard Apache2 installation page as shown below.

We now need to get the installation script from the Pihole website. Once again, login to your server via SSH and become root user.

sudo su -

cd /var/www/html

wget -O

Using your favourite command line text editor, in my case that’s vi edit the script and make the following changes:

Insert the following into line 3 of the script:


Next you need to scroll down until you find the following line in the script.


Change this line to false as shown below.


Now save the changes to the script and exit your editor.

Now we need to set the executable bit on the script and run it.

chmod 700 ./


Run through the installer as normal selecting the options that you require. Note that it will not install lighttpd web server.

You now need to reset the Pihole admin password to something of your choosing, use the following command to do this.

pihole -a -p

Once this is done we need to make some changes to the /etc/group file as shown below. Edit /etc/group using your favourite command line editor.

Add user www-data to the pihole group.


Next we need to add the pihole user to the www-data group.


Save the /etc/group file and exit your editor. To make these changes take effect we need to reboot the server.


When the server comes back up, login to the web interface using your web browser pointing it to the IP address of your server with /admin on the end.

Change the IP Address above to suit your installation.

At this point your Pihole DNS server is fully operational. You now need to start using it for the main screen to fully populate with data.

More soon …