Personal Privacy

Login Advanced Search
     General TopicsSelf Hosted ServicesServer Setup

Ad Blocking with Pi-Hole

Installation

First, install using

cd ~
git clone --depth 1 https://github.com/pi-hole/pi-hole.git Pi-hole
cd Pi-hole/automated\ install/
sudo bash basic-install.sh

In the next screens, choose the the appropriate network interface. Then, choose the DNS provider (Quad 9) and choose not to install LightHTTP. In the last screen, you will receive the password. If you need to change it later, use

pihole -a -p

To check if the server works, use

host google.com 127.0.0.1

Check the status using

sudo systemctl status pihole-FTL

Adjust the firewall settings

sudo ufw allow 53
sudo ufw reload

Web Interface for Admin Panel

YOU NEED TO HAVE php8.x-fpm installed!

sudo apt install php8.1-fpm

Then

sudo nano /etc/nginx/sites-available/pihole.conf
Then,
upstream php-handler {
  server unix:run/php/php8.1-fpm.sock;
}
server {
  listen 80;
  root /var/www/html;
  server_name _;
  autoindex off;

  index pihole/index.php index.php index.html index.htm;

  location / {
    expires max;
    try_files $uri $uri/ =404;
  }

  location ~ \.php$ {
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
    fastcgi_pass unix:/run/php/php8.1-fpm.sock;
    fastcgi_param FQDN true;
  }

  location /*.js {
    index pihole/index.js;
  }

  location /admin {
    root /var/www/html;
    index index.php index.html index.htm;
  }
}

Then

sudo ln -s /etc/nginx/sites-available/pihole.conf /etc/nginx/sites-enabled/pihole.conf
sudo chown -R www-data:www-data /var/www/html
sudo htpasswd -c /etc/nginx/.htpasswd admin
sudo usermod -aG pihole www-data

To see the webpage, go to http://WEBSITE_IP_ADDRESS/admin
To update Pi-Hole

pihole -up

Buy me a coffe?!


Comments

No comments yet!
Add a new comment:

10