Example PHP 7.3 & Httpd 2.4 setup for Docker, build on CentOS Linux. The image is only +/- 1373 GB large.
Repository: https://github.com/leonardofaria00/centos7-httpd-php73
- Built on the lightweight and secure CentOS Linux distribution
- Very small Docker image size (+/- 1583 GB)
- Uses PHP 7.3 for better performance, lower cpu usage & memory footprint
- Optimized for 100 concurrent users
- Optimized to only use resources when there's traffic (by using PHP-FPM's ondemand PM)
- The servers Httpd, PHP run under a non-privileged user (apache) to make it more secure
- The logs of all the services are redirected to the output of the Docker container (visible with
docker logs -f <container name>
) - Follows the KISS principle (Keep It Simple, Stupid) to make it easy to understand and adjust the image to your needs
Please note that the new builds since 26/01/2019 are exposing a different port to access Httpd. To be able to run Httpd as a non-privileged user, the port it's running on needed to change to a non-privileged port (above 1024).
The last build of the old version that exposed port 80 was leonardofaria00/centos7-httpd-php73:latest
Start the Docker container:
docker run -p 80:80 leonardofaria00/centos7-httpd-php73
See the PHP page on http://localhost, or the aplication page running app-start.sh with entrypoint
Or mount your own code to be served by PHP-FPM & Httpd
docker run -p 80:8080 -v ~/my-codebase:/var/www/html leonardofaria00/centos7-httpd-php73:latest
In config/ you'll find the default configuration files for Httpd, PHP and PHP-FPM. If you want to extend or customize that you can do so by mounting a configuration file in the correct folder;
PHP configuration:
docker run -v "`pwd`/config/php.ini:/etc/php.d/custom.ini" leonardofaria00/centos7-httpd-php73
Note; Because -v
requires an absolute path I've added pwd
in the example to return the absolute path to the current directory
If you need composer in your project, here's an easy way to add it;
FROM leonardofaria00/centos7-httpd-php73:latest
# Install composer from the official image
COPY --from=composer /usr/bin/composer /usr/bin/composer
# Run composer install to install the dependencies
RUN composer install --optimize-autoloader --no-interaction --no-progress