Caddy Server 2 + PHP-FPM Installation on Linux

Start with downloading Caddy 2 Linux binary.

Rename it as caddy.

mv caddy2* caddy

Move file to /usr/bin

mv caddy /usr/bin/

Add a group called caddy

groupadd --system caddy

Add a user to the group

useradd --system \
	--gid caddy \
	--create-home \
	--home-dir /var/lib/caddy \
	--shell /usr/sbin/nologin \
	--comment "Caddy web server" \

Go to /etc/systemd/system/ and download caddy.service file.

cd etc/systemd/system

Go to /etc and create a caddy directory.

cd etc
mkdir caddy

Create a Caddyfile in /etc/caddy folder with sample content below. {
root * /var/www/html/
try_files {path} {path}/ /index.php?{query}
php_fastcgi unix//run/php/php7.3-fpm.sock

Install PHP-FPM

apt install php-fpm

Start and enable PHP-FPM as a service.

systemctl enable php7.3-fpm
systemctl start php7.3-fpm

Start Caddy as a service.

sudo systemctl daemon-reload
sudo systemctl enable caddy
sudo systemctl start caddy

Note that, If you’re using Ubuntu 18.04 then your php-fpm version is 7.2