Skip to content

dalibor91/docker-apache2-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dockerised PHP & apache2

Repo provides tooling for building images that have baked in PHP, composer and apache2.

Supported versions of PHP:

  • PHP 5.6
  • PHP 7.0
  • PHP 7.1
  • PHP 7.2
  • PHP 7.4
  • PHP 8.0
  • PHP 8.1
  • PHP 8.2
  • PHP 8.3
  • PHP 8.4

Published images can be found on docker hub

Building

To build different images first you need to set image name that will be used as base. This is done by setting IMAGE_REPO variable and different versions will be appended as tags to this name.

# For example base image 'dbor91/apache2-php'

export IMAGE_REPO="dbor91/apache2-php" 

Building All Versions

To build all supported versions you can simply run

bin/build-image 

This will loop over all supported versions and create images, to list them all

docker image ls | grep $IMAGE_REPO

Building Specific Versions

To build specific version you need to specify IMAGE_VERSION variable

# for example 7.4 

export IMAGE_VERSION="7.4"

Then just run same script as for building all images

bin/build-image 

Publishing

You can generate publish command for all built images by simply running

docker image ls | grep $IMAGE_REPO | awk '{ print "docker push "$1":"$2 }'

Debugging

bin/build-image produces record.log file which logs which docker commands we run and output of those, can be used to debug if something fails

Testing

To test different versions you can use docker compose to check built images. Setting PHP_VERSION variable to specify which version you want to run before docker compose allows you to switch between different versions.

To just print php version in terminal run

PHP_VERSION="5.6" docker compose run php php -r 'echo phpversion();'
PHP_VERSION="7.0" docker compose run php php -r 'echo phpversion();'
PHP_VERSION="7.1" docker compose run php php -r 'echo phpversion();'
PHP_VERSION="7.2" docker compose run php php -r 'echo phpversion();'
PHP_VERSION="7.4" docker compose run php php -r 'echo phpversion();'
PHP_VERSION="8.0" docker compose run php php -r 'echo phpversion();'
PHP_VERSION="8.1" docker compose run php php -r 'echo phpversion();'
PHP_VERSION="8.2" docker compose run php php -r 'echo phpversion();'
PHP_VERSION="8.3" docker compose run php php -r 'echo phpversion();'
PHP_VERSION="8.4" docker compose run php php -r 'echo phpversion();'

If you want to see php version from apache2 simply run command bellow targeting correct PHP version and visit localhost:8080 in browser

PHP_VERSION="5.6" docker compose run --service-ports php
PHP_VERSION="7.0" docker compose run --service-ports php
PHP_VERSION="7.1" docker compose run --service-ports php
PHP_VERSION="7.2" docker compose run --service-ports php
PHP_VERSION="7.4" docker compose run --service-ports php
PHP_VERSION="8.0" docker compose run --service-ports php
PHP_VERSION="8.1" docker compose run --service-ports php
PHP_VERSION="8.2" docker compose run --service-ports php
PHP_VERSION="8.3" docker compose run --service-ports php
PHP_VERSION="8.4" docker compose run --service-ports php

About

Multiple versions of php in docker with apache2

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published