I just needed to spin up a new PHP webserver and I was amazed how fast and easy it was, nowadays. I mean: Caddy already makes it pretty easy, but I was delighted to see that, since the last time I did this, the default package repositories had 100% of what I needed!
Apart from setting the hostname, creating myself a user and adding them to the sudo group, and reconfiguring sshd to my preference, I’d
done nothing on this new server. And then to set up a fully-functioning PHP-powered webserver, all I needed to run (for a domain “example.com”) was:
sudo apt update && sudo apt upgrade -y sudo apt install -y caddy php8.4-fpm sudo mkdir -p /var/www/example.com printf "example.com {\n" | sudo tee /etc/caddy/Caddyfile printf " root * /var/www/example.com\n" | sudo tee -a /etc/caddy/Caddyfile printf " encode zstd gzip\n" | sudo tee -a /etc/caddy/Caddyfile printf " php_fastcgi unix//run/php/php8.4-fpm.sock\n" | sudo tee -a /etc/caddy/Caddyfile printf " file_server\n" | sudo tee -a /etc/caddy/Caddyfile printf "}\n" | sudo tee -a /etc/caddy/Caddyfile sudo service caddy restart
After that, I was able to put an index.php file into /var/www/example.com and it just worked.
And when I say “just worked”, I mean with all the bells and whistles you ought to expect from Caddy. HTTPS came as standard (with a solid QualSys grade). HTTP/3 was supported with a 0-RTT handshake.
Mind blown.
0 comments