Skip to content

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

License

Notifications You must be signed in to change notification settings

tdmalone/docker-apache-phpX

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Why?

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:

$ PHP_VERSION=5.3
$ 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}

Building

To build the PHP 5.3 image yourself:

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

$ git clone https://github.com/tdmalone/docker-apache-phpX.git
$ 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.

Development

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.

TODO

  • 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)

License

MIT.

Releases

No releases published

Packages

No packages published