Alpine PHP-FPM runtime with Composer, common extensions, OPcache, and FastCGI healthcheck.
226
A lightweight PHP-FPM runtime image based on the official Alpine PHP images.
Designed for Laravel and other PHP applications running behind Nginx or another FastCGI-compatible web server.
php:<version>-fpm-alpine imageswww-data with UID/GID 1000docker logs| Tag | Description |
|---|---|
8.5 | PHP 8.5 with PHP-FPM |
8.4 | PHP 8.4 with PHP-FPM |
8.3 | PHP 8.3 with PHP-FPM |
8.2 | PHP 8.2 with PHP-FPM |
7.4 | Legacy PHP 7.4 image |
PHP 7.4 is end-of-life and no longer receives security updates. Use it only for legacy applications.
docker pull oauthq/php:8.5
Run PHP-FPM:
docker run --rm \
--name php-fpm \
-v "$(pwd):/var/www/html:ro" \
oauthq/php:8.5
PHP-FPM listens on:
0.0.0.0:9000
Do not publish port 9000 directly to the public Internet. PHP-FPM should only be accessible through a trusted private Docker network.
FROM oauthq/php:8.5
COPY --chown=www-data:www-data . /var/www/html
The image includes the install-php-extensions script.
Create a downstream Dockerfile:
FROM oauthq/php:8.5
# The base image runs as www-data.
# Switch to root while installing PHP extensions.
USER root
RUN install-php-extensions imagick pdo_pgsql
COPY --chown=www-data:www-data . /var/www/html
# Return to the non-root application user.
USER www-data
Build the downstream image:
docker build -t myapp/php:8.5 .
Run it:
docker run --rm \
--name myapp-php \
myapp/php:8.5
The default extensions include:
bcmath
intl
gd
gettext
mysqli
mbstring
curl
opcache
pcntl
pdo_mysql
redis
zip
For PHP 8.5, OPcache is built into PHP and must not be installed again.
Xdebug can be installed in a development-only image:
FROM oauthq/php:8.5
USER root
RUN install-php-extensions xdebug
COPY xdebug.ini /usr/local/etc/php/conf.d/zz-xdebug.ini
USER www-data
Example xdebug.ini:
[xdebug]
xdebug.mode=develop,debug
xdebug.start_with_request=yes
xdebug.client_host=host.docker.internal
xdebug.client_port=9003
Do not install Xdebug in production unless it is explicitly required.
Example Nginx configuration:
server {
listen 80;
server_name _;
root /var/www/html/public;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_pass php:9000;
}
location ~ /\. {
deny all;
}
}
The hostname php should match the PHP-FPM service name in Docker Compose or the Docker network.
The image includes a FastCGI healthcheck.
Default settings:
FCGI_CONNECT=127.0.0.1:9000
FCGI_PING_PATH=/ping
The FPM pool also exposes:
/ping
/status
The healthcheck verifies PHP-FPM and FastCGI availability. It does not verify the application, database, Redis, or other external services.
Example Docker Compose healthcheck:
services:
php:
image: oauthq/php:8.5
healthcheck:
test: ["CMD", "php-fpm-healthcheck"]
interval: 10s
timeout: 3s
start_period: 10s
retries: 3
Add application-specific PHP settings in a downstream image:
FROM oauthq/php:8.5
COPY php.ini /usr/local/etc/php/conf.d/zzz-app.ini
COPY fpm.conf /usr/local/etc/php-fpm.d/zzz-runtime.conf
Example upload configuration:
upload_max_filesize = 32M
post_max_size = 35M
Example PHP-FPM process configuration:
[www]
pm.max_children = 10
pm.start_servers = 2
pm.min_spare_servers = 2
pm.max_spare_servers = 5
pm.max_requests = 500
Tune PHP-FPM process limits according to the memory available to the container.
PHP-FPM errors and worker output are sent to stderr:
docker logs php-fpm
docker logs -f php-fpm
Configure Docker log rotation in production:
services:
php:
image: oauthq/php:8.5
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
| Path | Purpose |
|---|---|
/var/www/html | Application directory |
/usr/local/etc/php/conf.d/ | PHP configuration files |
/usr/local/etc/php-fpm.d/ | PHP-FPM pool configuration |
/usr/local/bin/composer | Composer executable |
/usr/local/bin/install-php-extensions | PHP extension installer |
/usr/local/bin/php-fpm-healthcheck | FastCGI healthcheck script |
docker run --rm oauthq/php:8.5 php -v
docker run --rm oauthq/php:8.5 php -m
docker run --rm oauthq/php:8.5 php-fpm -tt
docker run --rm oauthq/php:8.5 php --ri "Zend OPcache"
MIT
Content type
Image
Digest
sha256:deaf334ba…
Size
63.6 MB
Last updated
22 days ago
docker pull oauthq/php:8.4