Joel Dare

Caddy PHP Config

This is a Caddyfile that configures Caddy to act pretty similar to PHP’s built-in web server. This works with legacy style apps. The Caddy documentation covers single page applications. {
    root * /var/www/example
    try_files {path} {path}/index.html {path}/index.php
    encode gzip
    php_fastcgi unix//run/php/php7.3-fpm.sock

Note that you’ll need to modify the name of the php7.3-fpm.sock file to match the name and version on your system. You typically find this in the /var/run/php/ directory, especially on Debian based Linux distributions.

See the Caddy documentation for some other Common Caddyfile Patterns.

Written by Joel Dare on October 18, 2022