CADDY , CONTAINERS , FEATURED , PHP

Fixing PHP-FPM Docker Container Logs

    2.3 minute read  

Coming from a more standard LAMP setup, a containerised Dockerised Caddy reverse-proxy with PHP FastCGI (PHP-FPM) is not as straightforward as you may expect!

Note: I'll reference "Docker" here but this should all work for the arguably better (more linuxy) "Podman" too.

The official PHP-FPM container does not log errors to the stdout (i.e. the terminal logs when running via docker-compose). This is not the standard for containers or ideal for containerised development or deployment.

The docs and blogs around the internet on this subject are almost all outdated, and so there's not a super clear solution. There are many parts to the php-fpm container config and most have been resolved in recent container image's apart from this last bit.

So, in 2025-11, there's three parts to get PHP error logs displaying in stdout; the config files which are mounted in via docker compose, the PHP ini config and then the fpm www config.

Project File Structure:

I use some relative paths below, and they expect this config to be in a sub-directory of your PHP projects root.

Docker Compose:

name: php-dev-server

services:

  caddy:
    container_name: caddy
    image: docker.io/caddy:latest
    volumes:
        - ../:/srv
        - ./conf:/etc/caddy
    ports:
        - 8080:8080

  php:
    container_name: php
    image: php:8.5-fpm
    volumes:
        - ../:/srv
        - ./php-dev.ini:/usr/local/etc/php/conf.d/php-custom.ini
        - ./fpm-www.conf:/usr/local/etc/php-fpm.d/zz-php-error-fix.conf
    #ports:
    #    - 9000:9000

Caddy config Caddyfile:

http://*:8080 {
	root * /srv

	# we specify http only above so if you want internal https, edit that too.
	tls internal

	# Enable the static file server.
	file_server

	# Or serve a PHP site through php-fpm:
	php_fastcgi php:9000
}

PHP-FPM config php-dev.ini:

short_open_tag = On
display_errors = On
html_errors = Off

PHP-FPM config fpm-www.conf:

[www]
php_admin_flag[log_errors] = on

Comments & Questions

Reply by email to send in your thoughts.

Comments may be featured here unless you say otherwise. You can encrypt emails with PGP too, learn more about my email replies here.

PGP: 9ba2c5570aec2933970053e7967775cb1020ef23

Recent posts