Skip to content

Arch Linux ARM Install Pi-Hole On A Raspberry Pi

Note

Pi-Hole is not officially supported on the Arch Linux operating system.

Prerequisites

Environment

Install Pi-Hole

  1. Install required packages.

    # pikaur -Syu pi-hole-server nginx-mainline php-fpm php-sqlite inetutils
    

    Info

    Pi-Hole Chronometer (pihole -c) utilizes the command "hostname" and therefore the package "inetutils" is required.

  2. Set Pi-Hole web interface administrator password.

    # pihole -a -p
    

  3. Enable PHP required extensions.
    # nano /etc/php/php.ini
    
    extension=curl
    extension=pdo_sqlite
    extension=sockets
    extension=sqlite3
    
  4. Set PHP read permissions.

    With the use of PHP v7.0 or newer, the PHP open_basedir directive defaults to empty. This means that PHP can therefore access every directory and file that can be read by the web server's user ID. For best security practice, the open_basedir directive will be intentionally set for the Pi-hole administrative web interface.

    $ nano /etc/php/php.ini
    
    open_basedir = /srv/http/pihole:/run/pihole-ftl/pihole-FTL.port:/run/log/pihole/pihole.log:/run/log/pihole-ftl/pihole-FTL.log:/etc/pihole:/etc/hosts:/etc/hostname:/etc/dnsmasq.d/02-pihole-dhcp.conf:/etc/dnsmasq.d/03-pihole-wildcard.conf:/etc/dnsmasq.d/04-pihole-static-dhcp.conf:/var/log/lighttpd/error-pihole.log:/proc/loadavg:/proc/meminfo:/proc/cpuinfo:/sys/class/thermal/thermal_zone0/temp:/tmp
    
    1. Create Nginx directory for site config.
    # mkdir /etc/nginx/conf.d
    
    1. Set Nginx general settings.
    # nano /etc/nginx/nginx.conf
    
    worker_processes  1;
    events {
        worker_connections  1024;
    }
    
    http {
        include             mime.types;
        default_type        application/octet-stream;
        sendfile            on;
        keepalive_timeout   65;
        gzip                on;
        gzip_min_length     1000;
        gzip_proxied        expired no-cache no-store private auth;
        gzip_types          text/plain application/xml application/json application/javascript application/octet-stream text/css;
    
        include /etc/nginx/conf.d/*.conf;
    }
    
    1. Create Nginx site config.
    # cp /usr/share/pihole/configs/nginx.example.conf /etc/nginx/conf.d/pi-hole.conf
    
    1. Edit Nginx site config and change fastcgi_pass.
    # nano /etc/nginx/conf.d/pi-hole.conf
    
    fastcgi_pass  unix:/run/php-fpm/php-fpm.sock;
    
    1. Set system hosts correctly.
    # nano /etc/hosts
    
    127.0.0.1              localhost
    ip.address.of.pihole   pi.hole myhostname
    
    1. Stop and disable "systemd-resolved.service".
    # systemctl stop systemd-resolved.service
    # systemctl disable systemd-resolved.service
    

    Note

    This is done because port 53 is used by "systemd-resolved.service" which will conflict with "pihole-FTL.service" port 53.

  5. Set php-fpm.service overrides.

    # systemctl edit php-fpm.service
    
    ### Anything between here and the comment below will become the new contents of the file
    
    [Service]
    ReadWritePaths = /srv/http/pihole
    ReadWritePaths = /run/pihole-ftl/pihole-FTL.port
    ReadWritePaths = /run/log/pihole/pihole.log
    ReadWritePaths = /run/log/pihole-ftl/pihole-FTL.log
    ReadWritePaths = /etc/pihole
    ReadWritePaths = /etc/hosts
    ReadWritePaths = /etc/hostname
    ReadWritePaths = /etc/dnsmasq.d/01-pihole.conf
    ReadWritePaths = /proc/meminfo
    ReadWritePaths = /proc/cpuinfo
    ReadWritePaths = /sys/class/thermal/thermal_zone0/temp
    ReadWritePaths = /tmp
    
    ### Lines below this comment will be discarded
    

    Note

    This step is required to grant Pi-Hole web interface access to the necessary files/directories.

  6. Enable web services.

    # systemctl enable nginx.service
    # systemctl enable php-fpm.service
    

  7. Start web services.
    # systemctl start nginx.service
    # systemctl start php-fpm.service
    
  8. Start Pi-hole services.
    $ pihole restartdns