Alpine PHP Webserver¶
A minimal Nginx + PHP-FPM Docker image built on Alpine Linux.
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
nobodyuser. - Fast —
ondemandFPM 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 ondemandFPM 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— justdocker logs -f - Trusted-proxy real IP support (
REAL_IP_FROM, Cloudflare, Tunnel) DISABLE_DEFAULT_LOCATIONto 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¶
- Quick Start — serve your
./phpdirectory in under a minute. - Docker Compose — local dev stacks, mounting code, building your own image.
- :material-nginx: Nginx Configuration — conf.d vs server-conf.d, custom routing, DISABLE_DEFAULT_LOCATION.
- PHP Configuration — custom.ini, OPcache, timezone, locale.
- Environment Variables — every supported knob.
- Reverse Proxy & Trusted IPs — Traefik, Nginx, Cloudflare, Cloudflare Tunnel.
- Composer & Building — recipes for building production images.
- Extending the Image — runit daemons, init scripts, running as root.
- Healthcheck & Logs — what
/fpm-pingdoes and where logs go. - Troubleshooting — solutions to recurring issues.
- FAQ — quick answers.
Minimal example¶
- http://localhost:8080/ —
phpinfo() - http://localhost:8080/test.html — static HTML probe
Mount your own code to serve it:
Project links¶
- Source code: https://github.com/erseco/alpine-php-webserver
- Docker Hub: https://hub.docker.com/r/erseco/alpine-php-webserver
- GitHub Container Registry:
ghcr.io/erseco/alpine-php-webserver - Issue tracker: https://github.com/erseco/alpine-php-webserver/issues