395
A collection of lightweight Nginx + PHP-FPM Docker images for hosting web applications and static/dynamic PHP-based files. Each directory represents a single PHP version, plus a nginxall variant that bundles most PHP versions into one image.
nginxall variant bundles multiple PHP versions at once; the active version is selected via the PHP_VERSION environment variable.--platform=linux/amd64 for x86_64 machines.packages.sury.org)../www) so no rebuild is needed when content changes.stdout / stderr to simplify docker logs.webserver/nginx/
├── nginx5.6/ # PHP 5.6 image
├── nginx7.0/ # PHP 7.0 image
├── nginx7.2/ # PHP 7.2 image
├── nginx7.4/ # PHP 7.4 image
├── nginx8.0/ # PHP 8.0 image
├── nginx8.1/ # PHP 8.1 image
├── nginx8.2/ # PHP 8.2 image
├── nginx8.3/ # PHP 8.3 image
├── nginx8.4/ # PHP 8.4 image
└── nginxall/ # Multi-PHP-version image
Each version directory shares the same structure:
nginx8.3/
├── Dockerfile # Image build definition
├── docker-compose.yml # Run orchestration (port, volume, container name)
├── docker/
│ ├── entrypoint.sh # Startup: start PHP-FPM + Nginx
│ └── nginx.conf # Nginx server config (root, index, PHP via FastCGI)
└── www/
└── index.php # Sample page (phpinfo)
| Component | Description |
|---|---|
| Web Server | Nginx (high-performance web server & reverse proxy) |
| Language | PHP-FPM (FastCGI Process Manager) |
| Protocol | FastCGI (Nginx → PHP-FPM via unix socket) |
| Architecture | x86_64 / amd64 (--platform=linux/amd64) |
| Base Image | Debian bookworm |
| Extra PHP Repo | Sury (packages.sury.org) for non-distro PHP versions |
| Directory | PHP | Container Name | Host Port | Built Image |
|---|---|---|---|---|
nginx5.6 | 5.6 | nginx-php56 | 9081 | nginx56-web |
nginx7.0 | 7.0 | nginx-php70 | 9082 | nginx70-web |
nginx7.2 | 7.2 | nginx-php72 | 9083 | nginx72-web |
nginx7.4 | 7.4 | nginx-php74 | 9084 | nginx74-web |
nginx8.0 | 8.0 | nginx-php80 | 9085 | nginx80-web |
nginx8.1 | 8.1 | nginx-php81 | 9086 | nginx81-web |
nginx8.2 | 8.2 | nginx-php82 | 9087 | nginx82-web |
nginx8.3 | 8.3 | nginx-php83 | 9088 | nginx83-web |
nginx8.4 | 8.4 | nginx-php84 | 9089 | nginx84-web |
nginxall | 5.6–8.4 | nginx-all | 9080 | gleenferdinand/nginx-web:all |
Note: The locally built image name follows the compose folder name (e.g.
nginx83-web). Thenginxallvariant has an explicit image taggleenferdinand/nginx-web:all.
Make sure Docker and Docker Compose v2 are installed, and that you are on an x86_64 / amd64 machine:
docker --version
docker compose version
uname -m # should report x86_64
Place your web files inside the www/ folder of the relevant directory, or use the bundled sample index.php.
cd webserver/nginx/nginx8.3
# Build the image
docker compose build
# Start the container
docker compose up -d
# Check status
docker compose ps
Access it in your browser:
http://localhost:9088
If the bundled www/index.php (phpinfo) is still present, the PHP configuration page will be displayed.
Repeat the same steps for the version directory you want. Adjust the port according to the table above:
cd webserver/nginx/nginx8.4
docker compose build
docker compose up -d
# Access http://localhost:9089
nginxall (all PHP versions)This image bundles several PHP-FPM versions at once. The default PHP version is determined by the PHP_VERSION environment variable (default 8.4).
cd webserver/nginx/nginxall
docker compose build
docker compose up -d
Switching the active PHP version:
# Set PHP_VERSION directly at run time
PHP_VERSION=7.4 docker compose up -d --force-recreate
# Or use .env
docker compose --env-file .env up -d
.env (for nginxall)The nginxall/.env file is already available and can be edited:
# Choose PHP version (5.6, 7.0, 7.2, 7.4, 8.0, 8.1, 8.2, 8.4)
PHP_VERSION=7.4
# Port for accessing the web (default 9080)
WORDPRESS_PORT=9080
After editing .env, rerun:
docker compose up -d --force-recreate
When the container starts, entrypoint.sh performs several steps:
/run/php directory for PHP-FPM sockets.php-fpm<v> matching the version in that directory.nginxall: starts all php-fpm5.6 … php-fpm8.4, then points the .php handler to the $PHP_VERSION socket.nginx -g 'daemon off;'.Web request flow:
Browser ──HTTP──▶ Nginx ──FastCGI socket──▶ php-fpm<v> ──▶ /var/www/html
docker/nginx.confA single server block that:
80 and serves the document root /var/www/html.index.php as the default index file./dev/stdout and /dev/stderr.try_files rewriting to index.php for pretty URLs / SPA-style routing..php files to PHP-FPM via fastcgi_pass unix:/run/php/php8.3-fpm.sock (version-specific in each image)..ht files for security../www:/var/www/html — your web content. Changes on the host are visible in the container immediately.Check container status & logs:
docker ps | grep nginx
docker logs <container_name> # e.g. docker logs nginx-php83
Test the page response:
curl -i http://localhost:9088
Check the active PHP version (if www/index.php contains phpinfo()):
curl -s http://localhost:9088 | grep -i "PHP Version"
| Symptom | Solution |
|---|---|
| Port already in use | Change the port in docker-compose.yml (the ports section). |
Blank page / .php extension downloaded | Make sure PHP-FPM is running; check docker logs <container>. |
php-fpm<v>: not found | Ensure the PHP version is actually installed in the image (or use the nginxall variant). |
| Old PHP version missing from Debian repo | The image uses the Sury repo; make sure the build uses docker compose build --pull. |
Wrong architecture / exec format error | These images require an x86_64 host. On ARM use the webserver/nginx_arm/ variant instead. |
| Want to reset / stop | Run docker compose down, then docker compose up -d to start again. |
| Configuration changes not applied | Files in docker/ are only read at build time; after editing them you must run docker compose build again. |
Note: This directory is the x86_64 / amd64 webserver variant. For ARM devices (e.g. Raspberry Pi / Apple Silicon), use the
webserver/nginx_arm/directory in the same repository.
Content type
Image
Digest
sha256:84e2609fc…
Size
117.5 MB
Last updated
about 2 months ago
docker pull gleenferdinand/nginx-web