Skip to content

Alpine PHP Webserver

A minimal Nginx + PHP-FPM Docker image built on Alpine Linux.

Docker Pulls Docker Image Size License MIT

What is this image?

erseco/alpine-php-webserver packages Nginx, PHP-FPM and a handful of common PHP extensions into a ~25 MB container ready to serve any PHP application. It is designed to be:

  • Small — Alpine base, single-process-group runtime via runit.
  • Secure — Nginx and PHP-FPM run as the unprivileged nobody user.
  • Fastondemand FPM process manager; Unix socket between Nginx and PHP; OPcache-ready.
  • Extensible — drop extra daemons into /etc/service/<name>/run, init scripts into /docker-entrypoint-init.d/, Nginx snippets into /etc/nginx/conf.d/ or /etc/nginx/server-conf.d/.
  • Configurable via env vars — every meaningful PHP / Nginx setting is templated at startup via envsubst.

This image is the base for erseco/alpine-moodle and powers numerous Symfony, Laravel, WordPress and plain PHP deployments.

Highlights

  • Alpine Linux 3.23, Nginx 1.28, PHP 8.4 FPM (see the Dockerfile for the actual versions in each tag)
  • Multi-arch: amd64, arm64, arm/v7, arm/v6, 386, ppc64le, s390x
  • ondemand FPM process manager — ~zero idle CPU
  • Unix-socket FastCGI for Nginx ↔ PHP (/run/php-fpm.sock)
  • Healthcheck on /fpm-ping (localhost-only by design)
  • Logs on stdout / stderr — just docker logs -f
  • Trusted-proxy real IP support (REAL_IP_FROM, Cloudflare, Tunnel)
  • DISABLE_DEFAULT_LOCATION to fully own the routing layer
  • Follows the KISS principle — the runtime is a few small shell scripts you can read in minutes

Where to start

Minimal example

docker run --rm -p 8080:8080 erseco/alpine-php-webserver

Mount your own code to serve it:

docker run --rm -p 8080:8080 -v "$PWD/php:/var/www/html" erseco/alpine-php-webserver