Skip to main content

🐘 PHP Configuration

PHP settings are templated from a single file — /etc/php84/conf.d/custom.ini.tpl — which the entrypoint runs through envsubst and writes to /etc/php84/conf.d/custom.ini. FPM pool settings (/etc/php84/php-fpm.d/www.conf) get the same treatment.

Concretely, anything you can change via a documented env var is already wired up. You don't need to mount a custom php.ini for the vast majority of settings.

Core runtime knobs​

VariableDefaultPurpose
memory_limit128MPer-request memory ceiling. Raise for Composer, Moosh, large imports. -1 = unlimited.
max_execution_time0Max seconds a script can run. 0 = unlimited.
max_input_time-1Max seconds parsing input (POST, GET, uploads). -1 = unlimited.
max_input_vars1000Max POST/GET variables per request. Raise for Moodle-style admin forms.
post_max_size8MMax POST body size. Must exceed upload_max_filesize.
upload_max_filesize2MMax individual file upload size.
file_uploadsOnEnable HTTP uploads.
display_errorsOffRender errors in responses. Leave off in production.
allow_url_fopenOnEnable URL-aware fopen wrappers.
allow_url_includeOffAllow include() from URLs. Leave off.
zlib_output_compressionOnTransparent output compression.
clear_envnoKeep env vars available to FPM workers.

Locale and timezone​

VariableDefaultPurpose
date_timezoneUTCdate.timezone in custom.ini. Use PHP timezone identifiers — Europe/Madrid, America/New_York, etc.
intl_default_localeen_USintl.default_locale in custom.ini. Used by the intl extension and Locale::getDefault().
environment:
date_timezone: Europe/Madrid
intl_default_locale: es_ES

OPcache​

OPcache is installed but disabled by default so that development mounts reflect changes immediately. Turn it on for production:

environment:
opcache_enable: "1"
opcache_memory_consumption: "256"
opcache_max_accelerated_files: "20000"
opcache_validate_timestamps: "0"
VariableDefaultPurpose
opcache_enable01 = enable OPcache.
opcache_memory_consumption256MB reserved for the opcode cache.
opcache_max_accelerated_files20000Max number of cached files (keep above your script count).
opcache_validate_timestamps00 = skip mtime checks (prod); 1 = revalidate each request (dev).
opcache_preload(empty)Path to a preload script.
realpath_cache_size4096KRealpath cache size.
realpath_cache_ttl600Realpath cache TTL in seconds.
opcache_validate_timestamps=0 + live mounts

With opcache_validate_timestamps=0, PHP will not re-read files on the fly. In production that is what you want (rebuild the image or restart the container on every deploy). In development, keep it at 1 or OPcache disabled.

Preloading​

environment:
opcache_enable: "1"
opcache_preload: /var/www/html/config/preload.php

Preload runs at FPM worker startup, so any error in the script will keep workers from booting. Start with a small preload file and grow it.

Bundled extensions​

The image ships with a curated set of PHP 8.4 extensions — enough for most frameworks out of the box:

  • Core: ctype, curl, dom, exif, fileinfo, iconv, intl, json, mbstring, openssl, session, simplexml, soap, sodium, tokenizer, xml, xmlreader, zip, zlib, phar
  • Image: gd
  • Databases: mysqli, pdo, pdo_mysql, pgsql, sqlite3
  • Performance: opcache, pecl-apcu

Need something else (e.g. ldap, redis, imagick)? Build a thin image on top — see Composer & Building:

FROM ruseler/alpine-php-webserver:latest
USER root
RUN apk add --no-cache php84-ldap php84-pecl-redis
USER nobody

Mounting your own php.ini snippet​

The entrypoint only manages custom.ini. You can drop additional .ini files into /etc/php84/conf.d/ and PHP will pick them up:

docker run --rm -p 8080:8080 \
-v "$PWD/90-my-app.ini:/etc/php84/conf.d/90-my-app.ini:ro" \
ruseler/alpine-php-webserver

Filename convention: NN-name.ini where NN controls load order. Use a number â‰Ĩ 90 to override the image defaults.

Verifying the running configuration​

# Effective settings (merged)
docker compose exec web php -i | head -60

# Just one setting
docker compose exec web php -r 'echo ini_get("memory_limit"), PHP_EOL;'

# Check which modules are loaded
docker compose exec web php -m

This documentation is a fork of erseco/alpine-php-webserver. The upstream documentation is available here.