PHP EOL
Docker images for old PHP versions
Do you need to run an old PHP application that can’t be rewritten for a supported PHP version overnight? The PHP project no longer releases fixes for the 5.x and 7.x branches or for 8.0 and 8.1, and support for 8.2 ends on 31 December 2026. An unpatched PHP version keeps running with all its known vulnerabilities. PHP EOL provides PHP-FPM and PHP CLI container images for these versions, and security fixes keep going into them.
The PHP builds come from CloudLinux’s alt-php packages. CloudLinux backports security fixes into these old versions as well, and publishes the package sources (SRPMs). We rebuild PHP from these source packages on AlmaLinux 9, and put only what is needed to run it into the image. You don’t need a CloudLinux licence: the licence only protects the repository of compiled packages, while the source packages are freely available. The project is not affiliated with CloudLinux.
It is for anyone who wants to run an old PHP application in a container until the move to a supported version is finished.
Supported versions
| PHP | Server image | CLI image | Server |
|---|---|---|---|
| 8.2 | 8.2-fpm |
8.2-cli |
PHP-FPM |
| 8.1 | 8.1-fpm |
8.1-cli |
PHP-FPM |
| 8.0 | 8.0-fpm |
8.0-cli |
PHP-FPM |
| 7.4 | 7.4-fpm |
7.4-cli |
PHP-FPM |
| 7.3 | 7.3-fpm |
7.3-cli |
PHP-FPM |
| 7.2 | 7.2-fpm |
7.2-cli |
PHP-FPM |
| 7.1 | 7.1-fpm |
7.1-cli |
PHP-FPM |
| 7.0 | 7.0-fpm |
7.0-cli |
PHP-FPM |
| 5.6 | 5.6-fpm |
5.6-cli |
PHP-FPM |
| 5.5 | 5.5-fpm |
5.5-cli |
PHP-FPM |
| 5.4 | 5.4-fpm |
5.4-cli |
PHP-FPM |
| 5.3 | 5.3-fpm |
5.3-cli |
PHP-FPM |
| 5.2 | 5.2-cgi |
5.2-cli |
php-cgi in FastCGI mode (5.2 has no FPM) |
The images are available at registry.gitlab.com/csbitbt/php-eol. The CLI image contains the same files as the server image of the same version; only the default command is different (php -a).
How the images are built
- Rebuilding the RPMs. In an
almalinux:9container we download the alt-php source packages and their alt-* dependencies (for example CloudLinux’s own builds of ICU, OpenSSL, curl and libxml2) from the CloudLinux 9 public repository, and then compile them. Every package is built in the same clean build environment. - Stubs. Some CloudLinux build packages have no public source (
alt-pkg-config,alt-build-macros,cl-MariaDB1011), and one does nothing in a container (cloudlinux-linksafe). These are replaced by small substitute packages that pull in AlmaLinux’s own equivalents. - Spec fixes. Where a CloudLinux spec file doesn’t suit the container build, we modify it with a sed script.
alt-libgd, for example, is built without AVIF, because the AVIF codecs would make the image about 35 MB larger, and PHP 7.4 doesn’t even use them. FROM scratchimage. The compiled RPMs are installed into an empty root directory, we remove the packages that aren’t needed at runtime (systemd, Perl, Python, etc.), and the result goes into aFROM scratchimage. The RPM database is kept, so vulnerability scanners (Trivy, Grype, Docker Scout, GitLab container scanning) can see the AlmaLinux packages.- Smoke test. Every image is checked by an automated test: the extensions load without warnings, no shared library is missing, the server accepts connections on port 9000, and the workers run as the
www-datauser; for the CLI image, it checks that scripts run. - CI. The GitLab pipeline only recompiles the packages for which CloudLinux has published a new release, but it rebuilds the images on every run, so AlmaLinux updates are included too. We rebuild the images when it is needed: when CloudLinux releases a new fix or the AlmaLinux base is updated.
- Tags. Every image gets two tags: a short one (
5.6-fpm) and one that marks the exact CloudLinux release (5.6.40-152-fpm). There is nolatesttag.
Usage
The FPM images work like the official php:*-fpm images:
php-fpmruns in the foreground and serves FastCGI on port 9000;- the workers run as the
www-datauser (uid/gid 33), and the document root is/var/www/html; - PHP and FPM log to standard error, so everything appears in the container log;
phpandphp-fpmare on thePATH.
docker run -d --name php -v "$PWD:/var/www/html" registry.gitlab.com/csbitbt/php-eol:5.6-fpm
You can put nginx in front of it like this, for example:
location ~ \.php$ {
fastcgi_pass php:9000;
fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;
include fastcgi_params;
}
PHP’s files are under /opt/alt/phpNN/ (for example /opt/alt/php56/), and PHP_INI_DIR points to its etc/ directory. You can put your own settings (memory_limit, date.timezone, etc.) in an .ini file in the link/conf/ directory, and the FPM pool settings in the etc/php-fpm.d/ directory.
The -cli images run the php command line, for example for cron jobs, queue workers or scripts. They contain no cron daemon; these jobs are started by the host’s cron or another scheduler:
docker run --rm --user www-data -v "$PWD:/var/www/html" registry.gitlab.com/csbitbt/php-eol:5.6-cli php cron.php
PHP 5.2. This image also serves FastCGI on port 9000, so the web server configuration is the same. Instead of FPM, php-cgi -b 0.0.0.0:9000 runs, and the whole container runs as the www-data user. The number of workers is fixed: PHP_FCGI_CHILDREN (30 by default), and each one restarts after PHP_FCGI_MAX_REQUESTS requests (2,000 by default).
Extensions
Enabled in every image: bcmath, calendar, curl, dom, exif, fileinfo, gd, gettext, igbinary, intl, json, mbstring, memcached, mysqli, mysqlnd, openssl, pcntl, pdo_mysql, pdo_sqlite, phar, posix, recode, xmlreader, xmlrpc, xmlwriter, zip and zlib. The differences:
- 8.0–8.2: no recode, json is built in, and xmlrpc comes from its PECL package.
- 7.4: no recode, because it was removed from PHP 7.4.
- 5.2: no mysqlnd; mysql, mysqli and pdo_mysql use AlmaLinux’s MariaDB Connector/C client library, which also connects to MySQL servers.
Some extensions are included in the image but not enabled, for example sockets, xsl, pdo_dblib, the old mysql_* functions in the 5.x versions, and ffi in 7.4 and 8.x. You can enable these in your own image with an extension= line. OPcache is in every image, but it is disabled by default; it can be loaded as a Zend extension with its full path:
FROM registry.gitlab.com/csbitbt/php-eol:5.6-fpm
RUN printf 'zend_extension=/opt/alt/php56/usr/lib64/php/modules/opcache.so\nopcache.memory_consumption=128\n' \
> /opt/alt/php56/link/conf/20-opcache.ini
Any other extension (for example soap, ldap, pgsql, or redis and imagick from PECL) needs its CloudLinux package, which can only be added when the image is built. For that, you have to build the project yourself; the README describes the steps.
Things to keep in mind
- These are EOL versions. The backported fixes are no substitute for moving on: the goal is migrating to a supported PHP version, and the image gives you time for that.
- The fixes come from CloudLinux. We don’t write our own PHP fixes; we rebuild CloudLinux’s packages, so the scope and pace of the fixes depend on them.
- No package manager and no
docker-php-ext-install. Anything that isn’t in the image can only be added with your own build. The oci8 extension isn’t built, because Oracle Instant Client has no public source. - x86-64 only. The RPMs and the images are built for the amd64 architecture.
- Tags are overwritten. On a rebuild, both the short and the exact tag point to the new build, and there is no
latest, so always specify the version. - PHP 5.3. FPM always clears the workers’ environment, so the container’s environment variables don’t reach PHP.
- Defaults. The default FPM pool is dynamic, with at most 70 workers; you should adjust this to the available memory. The CLI images run as root; for jobs that work on the web application’s files, add the
--user www-dataoption.