Caddy PHP Config

By Joel Dare - Written October 18, 2022

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.

example.com {
    root * /var/www/example
    try_files {path} {path}/index.html {path}/index.php
    encode gzip
    php_fastcgi unix//run/php/php7.3-fpm.sock
    file_server
}

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.

If you have questions, comments, or corrections for this post, please email them to me.

JoelDare.com © Dare Companies Dotcom LLC

Terms - Privacy