Lightweight & optimized Multi-Arch Docker Images (x86_64
/arm
/arm64
) for Nginx 1.25.3 & PHP-FPM 8.3) with essential extensions on top of latest Alpine Linux.
Example PHP-FPM 8.3 & Nginx 1.25 container image for Docker, built on Alpine Linux.
Repository: https://github.com/bitscoid/nginx-php-lite
- Built on the lightweight and secure Alpine Linux distribution
- Multi-platform, supporting AMD4, ARMv6, ARMv7, ARM64
- Very small Docker image size (+/-40MB)
- Uses PHP 8.3 for the best performance, low CPU usage & memory footprint
- Optimized for 100 concurrent users
- Optimized to only use resources when there's traffic (by using PHP-FPM's
on-demand
process manager) - The services Nginx, PHP-FPM and supervisord run under a non-privileged user (nobody) 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>
)
I can help you with Web & App Development, Containerization, Kubernetes, Monitoring, Infrastructure as Code..
The goal of this container image is to provide an example for running Nginx and PHP-FPM in a container which follows the best practices and is easy to understand and modify to your needs.
Start the Docker container:
docker run -p 80:80 bantenitsolutions/nginx-php-lite
See the PHP info on http://localhost
Or mount your own code to be served by PHP-FPM & Nginx
docker run -p 80:80 -v ~/app:/var/www/bits bantenitsolutions/nginx-php-lite
In nginx and php directory you'll find the default configuration files for Nginx, 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;
Nginx Configuration:
docker run -v "./server/nginx/nginx.conf:/etc/nginx/http.d/default.conf" bantenitsolutions/nginx-php-lite
Nginx Default Site:
docker run -v "./server/nginx/http.d/default.conf:/etc/nginx/http.d/default.conf" bantenitsolutions/nginx-php-lite
PHP Configuration:
docker run -v "./server/php/php.ini:/usr/local/etc/php/php.ini" bantenitsolutions/nginx-php-lite
PHP-FPM Configuration:
docker run -v "./server/php/www.conf:/usr/local/etc/php-fpm.d/www.conf" bantenitsolutions/nginx-php-lite
Add extra PHP modules
You may use this image as the base image to build your own. For example, to add mongodb module: Create a Dockerfile
FROM bantenitsolutions/nginx-php-lite
RUN apk add --no-cache --update --virtual .phpize-deps $PHPIZE_DEPS \
&& apk add --no-cache --update --virtual .all-deps $PHP_MODULE_DEPS \
&& pecl install mongodb \
&& docker-php-ext-enable mongodb \
&& rm -rf /tmp/pear \
&& apk del .all-deps .phpize-deps \
&& rm -rf /var/cache/apk/* /tmp/* /var/tmp/*
Build Image
docker build -t my-nginx-php-lite .
To modify this container to your specific needs please see the following examples;