If you don't specifically need to separate Apache from PHP, then you might be good to go with an official php:5.6-apache image which comes with Apache out of the box.
For example, your docker-compose.yml might look something like this:
version: '3' services: web: image: php:5.6-apache ports: - "8080:80" # Map container port 80 to host machine port 8080 volumes: - ".:/var/www/html" # Mount current folder as volume to container at /var/www/html
Or, for a more real-life example, if you also need at least one of the following:
- A custom web root (for Laravel, Symfony, etc)
- Other Apache modules installed
- Other PHP extensions installed
You might do something more like this:
version: '3' services: web: build: context: . dockerfile: Dockerfile ports: - "8080:80" # Map container port 80 to host machine port 8080 environment: APACHE_DOCUMENT_ROOT: "/var/www/yourapp.com/public" volumes: - ".:/var/www/yourapp.com" # Mount current folder as volume to container at /var/www/yourapp.com
And then your Dockerfile (which we reference from the docker-compose.yml above):
FROM php:5.6-apache # Declare an environment variable with a default value for changing Apache's document root # We will override this in docker-compose.yml ENV APACHE_DOCUMENT_ROOT /var/www/html # Configure web root RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf # Install additional Apache modules # This example: mod_rewrite & mod_headers RUN a2enmod rewrite headers # Install additional PHP extensions # This example: memcached & mysqli # For other extensions see official docs: # https://hub.docker.com/_/php (section: How to install more PHP extensions) RUN apt-get update && apt-get install -y libmemcached-dev zlib1g-dev \ && pecl install memcached-2.2.0 \ && docker-php-ext-enable memcached \ && docker-php-ext-install -j$(nproc) mysqli
php-fpmthat run on some port and then you need to configure thephp-fpmin your apache config file.