Pi Hole and a website

Hello, I want to use my Pi-hole to host a small local website , I do mean local, because I asked the same question on Reddit and people seem to confuse local and public. So I was told I could install Apache alongside Pi-hole, okay, but is there a cleaner way by using the server already built into Pi-hole, CivetWeb, to host my site? I should point out that my small local site runs with PHP, and it’s just a configuration interface for Pi-hole, but slightly reworked.

Thank you for your help.

I am not certain if it would be possible to leverage the ‘built-in’ web server, as it’s meant for Pi-hole only. I use lighttpd myself. Since the v5 Pi-hole used to install and use that, over the years I added on functionality needing/using that web server. In the now v6 days, I migrated my setup to still use lighttpd and proxy to both the Pi-hole interface and APIs as well as act as a reverse proxy for DoH. My lighttpd also serves up basic error and landing pages as well as rpimonitor. It’s light-weight and can provide many mods for specific needs.

So the best is to install Apache next to Pi Hole?

I'm not sure if this will work.

Civetweb can run PHP, but our embedded version doesn't have any specific configuration to execute PHP files. I never tried to run PHP using pihole-FTL web server. Also, I never heard about other users successfully doing it.

You can try it, but I think using apache or nginx to run PHP will probably be easier.

So how to install Apache next to Pi Hole

Yesterday, I answered a very similar question, on Reddit:

If you want to run Pi-hole and another web server at the same time, you need to install the other web server, then use different ports for each of them.

Examples:

  • Pi-hole using ports 80 and 443 and Apache using other ports, like 8880 and 8443 or
  • Apache using ports 80 and 443 and Pi-hole using other ports, like 8080 and 8443.

Note:

If you want to change Pi-hole settings to use custom ports, run this command:

sudo pihole-FTL --config webserver.port '8080o,8443so'

thanks you for your help

ok but so example I just installed pi hole, then install apache "sudo apt install apache2" modify the ports.conf file of apache by listening on ports 8080 and 8443 and is it okay?

The command above will change Pi-hole ports.

Pi-hole web interface will use ports 8080 and 8443. Then you will need to access the web interface using these ports:

Apache will use whatever ports you like (the default ones are 80 and 443).

ok thanks

I'm a little confused. Should I use a reverse proxy? Should I use Docker?

I think you are...

You can use a Reverse proxy, you can use Docker and you can use both at the same time...

They are completely different solutions, to different problems:

A reverse proxy handles how you will connect to a domain. A reverse proxy is a server that sits in front of web servers, acting as an intermediary between the browser and the web server, usually forwarding connections to different ports.

Docker will run Pi-hole (and also a reverse proxy, if you want it) inside containers.

ok so if I just want a small local website (that uses php) on the same PI as pi hole, how do I do it?

This is 100% unrelated to Pi-hole.

Search how to install Apache and PHP on your OS (this is out of scope here).

Then you execute the command I gave you above:

sudo pihole-FTL --config webserver.port '8080o,8443so'

And access Pi-hole web interface using this URL: http://pi.hole:8080/admin

The other website (your PHP web site) will be accessed using the port you configure on Apache.

ok thank you I'll try

its work, thank you bro