Prophusion for Apache
This docker image makes it fast and easy to switch amongst any PHP versions
within the Apache webserver since 5.3.9.
It is built from the prophusion-base image, and the
characteristics of the php builds are very similar.
- Install docker
In your terminal, run this command:
docker run -it -p 8080:80 -e "PHP_VERSION=7.0.10" prophusion/prophusion-apache /bin/bash
The prophusion-apache docker image will download and start. Then PHP 7.0.10 will be loaded
into the container and configured in apache.
- On your docker host, visit
http://localhost:8080in a web browser. You should be greeted with a default page showing the
phpinfo() for PHP 7.0.10.
- You can test another PHP version, say 5.6.25, by running the following command in the container:
prophusion apache-version 5.6.25
Note: Changing the PHP version used by Apache causes Apache to restart.
Running your own app
To have the container host your code instead of the stylish default phpinfo page, mount it in the
/var/www/html. For example, if you have an app on your docker host at
you could run
docker run -p 8080:80 -v /path/to/my-killer-app:/var/www/html -e "PHP_VERSION=7.0.0" prophusion/prophusion-apache
Changing the PHP version from the docker host
When you do not tell the container to run a shell such as
/bin/bash as part of your
docker run, it will tail
apache's logs until it is stopped with
docker stop. You will not have a shell in the container in this case,
but you can still change the PHP version used by running this command from the docker host:
docker exec [container-name] prophusion apache-version [new.php.version]
container-name is the container name or id as listed by
docker ps, and
is the next php version you want the container to run.
The container prints an example of this command including the correct
container-name when it starts up.