ℹ️ About Alpine PHP Webserver
A minimal Nginx + PHP-FPM Docker image built on Alpine Linux.
Attribution
This documentation is a fork of erseco/alpine-php-webserver. The upstream documentation is available here.
What is this image?
ruseler/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 ruseler/alpine-moodle and powers numerous Symfony, Laravel, WordPress and plain PHP deployments.
Features
- Lightweight: built on Alpine Linux for a compact final image
- Nginx + PHP-FPM: runs both via
runit, avoiding the overhead ofsupervisord - Non-root by default: Nginx and PHP-FPM run as
nobodyfor improved security - Environment-variable driven: tune PHP limits, OPcache, timeouts, and reverse-proxy/trusted-IP settings without touching config files
- Healthcheck included: built-in
HEALTHCHECKhitting the FPM ping endpoint - Composer-friendly: designed to be extended with Composer-based builds for your own PHP projects
Where to start
- 🚀 Quick Start — serve your
./phpdirectory in under a minute. - 🐳 Docker Compose — local dev stacks, mounting code, building your own image.
- ⚙️ 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
docker push ruseler/alpine-php-webserver:tagname
docker run --rm -p 8080:8080 ruseler/alpine-php-webserver
- http://localhost:8080/ —
phpinfo() - http://localhost:8080/test.html — static HTML probe
Mount your own code to serve it:
docker run --rm -p 8080:8080 -v "$PWD/php:/var/www/html" ruseler/alpine-php-webserver
Project links
- Source code: https://github.com/AdrianoRuseler/alpine-php-webserver
- Docker Hub: https://hub.docker.com/r/ruseler/alpine-php-webserver
- Issue tracker: https://github.com/AdrianoRuseler/alpine-php-webserver/issues
This documentation is a fork of erseco/alpine-php-webserver. The upstream documentation is available here.