Debian install PHP and Caddy for Pi-hole

Server environment
1. Debian9 sid

Updated May 12, 2019

Install PHP 7.3 PPA

sudo apt -y install lsb-release apt-transport-https ca-certificates 
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php7.3.list

Install PHP7.3 

// apt install 
apt-get -y install curl php7.3-cli php7.3-fpm php7.3-mysql php7.3-curl php7.3-gd php7.3-intl php-pear php7.3-imap php7.3-pspell php7.3-recode php7.3-sqlite3 php7.3-tidy php7.3-xmlrpc php7.3-xsl php7.3-mbstring php-gettext

Install Caddy

curl https://getcaddy.com | bash -s personal
// Caddy binary file will store at
/usr/local/bin/caddy

// Change permission
sudo chown root:root /usr/local/bin/caddy 
// permissions 
sudo chmod 755 /usr/local/bin/caddy

Config a site with PHP

// Edit Caddy file
nano /etc/caddy/CaddyFile

https://xx.com:81 {
    root /var/www/html/admin
    log /var/log/caddy/pihole.review.log 
    errors /var/log/caddy/errors.log
    #basicauth / admin password
    tls /etc/letsencrypt/live/xx.com/fullchain.pem /etc/letsencrypt/live/xx.com/privkey.pem
    gzip
	
    fastcgi / /var/run/php/php7.0-fpm.sock php {
        ext .php
        split .php
        index index.php
    }
    rewrite {
		to {path} {path}/ /index.php?page={uri_escaped}
    }
}

Photo by Kobu Agency on Unsplash

References

  1. https://dengxiaolong.com/caddy/zh/example.cmsmadesimple.html
  2. https://computingforgeeks.com/how-to-install-php-7-3-on-debian-9-debian-8/