Home

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.

Build your next site in pure HTML and CSS

Want to build your next site in pure HTML and CSS? Join the free Five-Day Neat Starter Email Course and build a lean, production-ready page before Friday.

Email Me the Crash Course


JoelDare.com © Dare Companies Dotcom LLC

Terms - Privacy