Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Docker, Apache and PHPx

Dockerfiles for running (almost) every minor version of PHP, with Apache.

Based on work originally by Alexander Schenkel.

PHP versions available:

PHP versions maybe coming soon:

  • PHP 5.2


Because sometimes, you have to work with old software, and it's not immediately straightforward to figure out how to on newer systems!

I put these together primarily as a tool to help me at work, where we're frequently upgrading old versions of WordPress and plugins that won't (yet) work on newer versions of PHP.

Quick Start

For PHP 5.3, for instance:

$ WEB_ROOT=/path/to/your/web/root
$ HOST_PORT=8080

$ docker run --rm --detach --publish ${HOST_PORT}:80 --volume ${WEB_ROOT}:/var/www --name php${PHP_VERSION} tdmalone/docker-apache-phpx:${PHP_VERSION}

This will download the pre-built image for PHP 5.3, and start a container named php5.3 on http://localhost:8080 (loading from the web root you supplied).

When you've finished, you can clean up (and automatically remove the container) by running:

$ docker stop php${PHP_VERSION}


To build the PHP 5.3 image yourself:

$ WEB_ROOT=/path/to/your/web/root
$ HOST_PORT=8080

$ git clone
$ docker build --tag php${PHP_VERSION} docker-apache-phpX/php${PHP_VERSION}
$ docker run --rm --detach --publish ${HOST_PORT}:80 --volume ${WEB_ROOT}:/var/www --name php${PHP_VERSION} php${PHP_VERSION}

If you set your web root to the folder that docker-apache-phpX was cloned into (eg. by running WEB_ROOT=$PWD), then you can visit http://localhost:8080/docker-apache-phpX/phpinfo.php to prove that you're running the PHP version you chose.


Ubuntu has been chosen for these Dockerfiles for its ease-of-use and large, well maintained package repository. Wherever possible, LTS releases are used for increased stability.

To assist in creating new images or debugging current ones, you may find these links helpful:

To debug an image, swap --detach with --interactive --tty and add bash to the end, like this:

$ docker run --rm --interactive --tty --publish ${HOST_PORT}:80 --volume ${WEB_ROOT}:/var/www --name php${PHP_VERSION} php${PHP_VERSION} bash

Then run run to simulate what would have happened if you started the container detached.

This repository is linked to an automated build at Docker Hub, with each subdirectory manually mapped to a version tag.


  • Make files writable by the web server
  • Increase the PHP upload limit to something much larger than the default
  • Make error logs available somewhere easy
  • Further documentation (eg. see Alexander's repo for more of the features he included, such as logging and setting error reporting level via an environment variable)




No releases published


No packages published