alpine + nginx + php-fpm + dockerize = easy PHP app server goodness
6.0K
This is a docker image for an alpine nginx + php-fpm combo container, with support for:
composer install if applicable)Inspired by richarvey/nginx-php-fpm, this image supports most of that image's configuration flags, plus many, many enhancements and bug fixes like these:
sed, and boolean environment variables can be set to true or false , not just 1 or 0/tpl)PHP_CONTROLLER to true and PUBLIC_DIR to the subdirectory that contains the relevant index.php (if any). (PATH_INFO support is also available, for e.g. Moodle.)DOMAIN and LETS_ENCRYPT=my@email: registration and renewals are immediate, painless, and 100% automatic. The certs are saved in a volume by default, and renewals happen on container restart, as well as monthly if you enable cron.USE_CRON=true and putting the job data in /etc/crontabs/nginx, or an executable file in one of the /etc/periodic/ subdirectories (via volume mount, startup script, or template files).ini files to /etc/supervisor.d/ to add additional processes to the base supervisor configuration, or to override the default supervisor configurations for nginx, php-fpm, etc.php-fpm pool parameters can be set with environment vars (FPM_PM, FPM_MAX_CHILDREN, FPM_START_SERVERS, FPM_MIN_SPARE_SERVERS, FPM_MAX_SPARE_SERVERS, FPM_MAX_REQUESTS)set_real_ip_from is recursive, and supports Cloudflare (via REAL_IP_CLOUDFLARE=true) as well as your own load balancers/proxies (via REAL_IP_FROM -- which can include multiple addresses, separated by spaces.)EXTRA_APKS, EXTRA_EXTS, and EXTRA_PECL as environment variables or build-time arguments.sendfile is turned on for optimal static file performance, unless you set VIRTUALBOX_DEV=truedeveloper user rather than as root, and files are owned by that user. To be written to by PHP and the web server, files or directories must be explicitly listed in NGINX_WRITABLE. (The whole codebase is NGINX_READABLE by default, but can be made more restrictive by listing specific directories.)/var/www/html (just set CODE_BASE to whatever directory you like)FATAL state, the entire container is shut down, so that configuration or other errors don't produce a silently unresponsive container./tmp, speeding start times for large PHP command line tools such as wp-cli, artisan, etc. (For compatibility reasons, this cache is disabled when ENABLE_XDEBUG is true.) Command-line scripts run without a memory limit, unless you set PHP_CLI_MEMORY to a memory value like 512M.Note: there are a few configuration options that must be specified in a different way than the richarvey image, or which have different defaults: see Backward-Compatibility Settings, below, for more info.
Builds of this image are tagged with multiple aliases to make it easy to pin specific revisions or to float by PHP version. For example, a PHP 7.3.13 image with release 2.1.1 of this container could be accessed via any of the following tags (if 2.1.1 were the latest release of this image):
7.37.3-2.x7.3-2.1.x7.3-2.1.17.3.137.3.13-2.x7.3.13-2.1.x7.3.13-2.1.1Note that there is no latest tag for this image; you must explicitly select at least a PHP version such as 7.3 to get the latest version of this image for that PHP version.
Also note that although you can just specify a PHP version, major releases of this container may be incompatble with older releases due to e.g. changes in OS versions or other factors, so you should probably at least target a specific major release of this container, e.g. 7.3-2.x or 7.4-3.x.
-alpine3.x tags so you can distinguish by OS version (e.g. 8.0-alpine3.16 vs 8.0-alpine3.18).GLOBAL_REQUIRE, added --optimize-autoloader to default COMPOSER_OPTIONS| Tags | PHP | nginx | mod lua | alpine | Notes |
|---|---|---|---|---|---|
| 8.3-3.1.x | 8.3.1 | 1.24.0 | 0.10.24 | 3.18 | These versions are also tagged with an -alpine version suffix |
| 8.2-3.1.x | 8.2.14 | 1.24.0 | 0.10.24 | 3.18 | |
| 8.1-3.1.x | 8.1.27 | 1.24.0 | 0.10.24 | 3.18 | |
| 8.0-3.1.x | 8.0.30 | 1.22.1 | 0.10.21 | 3.16 | |
| 7.4-3.1.x | 7.4.33 | 1.22.1 | 0.10.21 | 3.16 | |
| 7.3-3.1.x | 7.3.33 | 1.20.1 | 0.10.19 | 3.14 | |
| 7.2-3.1.x | 7.2.34 | 1.18.0 | 0.10.15 | 3.12 | |
| 7.1-3.1.x | 7.1.33 | 1.16.1 | 0.10.15 | 3.10 | |
| 8.2-3.0.x | 8.2.3 | 1.22.1 | 0.10.21 | 3.16 | Composer 2 |
| 8.1-3.0.x | 8.1.16 | 1.22.1 | 0.10.21 | 3.16 | |
| 8.0-3.0.x | 8.0.19 | 1.20.1 | 0.10.19 | 3.14 | |
| 7.4-3.0.x | 7.4.22 | 1.20.1 | 0.10.19 | 3.14 | |
| 7.3-3.0.x | 7.3.29 | 1.20.1 | 0.10.19 | 3.14 | |
| 7.2-3.0.x | 7.2.34 | 1.18.0 | 0.10.15 | 3.12 | |
| 7.1-3.0.x | 7.1.33 | 1.16.1 | 0.10.15 | 3.10 | |
| 7.3-2.x | 7.3.13 | 1.14.2 | 0.10.15 | 3.9 | New extension build method for all 7.x-2.x versions |
| 7.2-2.x | 7.2.26 | 1.14.2 | 0.10.15 | 3.9 | |
| 7.1-2.x | 7.1.33 | 1.14.2 | 0.10.15 | 3.9 | |
| 7.2.26-1.4.x | 7.2.26 | 1.14.2 | 0.10.15 | 3.9 | Old extension build method used from here down |
| 7.1.33-1.4.x | 7.1.33 | 1.14.2 | 0.10.15 | 3.9 | |
| 1.4.x | 7.1.33 | 1.14.2 | 0.10.15 | 3.9 | |
| 1.4.0 | 7.1.32 | 1.14.2 | 0.10.15 | 3.9 | |
| 1.0.x - 1.3.x | 7.1.12 | 1.13.7 | 0.10.11 | 3.6 | Based on upstream 1.3.10 |
Content type
Image
Digest
sha256:3e88eb617…
Size
98.3 MB
Last updated
over 1 year ago
docker pull dirtsimple/php-server:8.3-alpine3.18