Repolode
TrafeX

TrafeX/docker-php-nginx

A small Alpine Linux Docker image that runs PHP-FPM 8.5 and Nginx together, serving PHP apps out of the box.

Stars
1,529
Forks
759
Open issues
2
Last commit
7 days ago

What is it?

This project is a Docker image that packages PHP-FPM 8.5 and Nginx 1.28 on Alpine Linux, so you can serve PHP applications without assembling the web server stack yourself. Mounting your code into /var/www/html is enough to start serving it, and configuration files for Nginx, PHP and PHP-FPM can be overridden with volume mounts.

The image targets small size and low idle resource use. It is built for AMD64, ARMv6, ARMv7 and ARM64, weighs roughly 40MB, and uses PHP-FPM's on-demand process manager so processes run only when there is traffic. Nginx, PHP-FPM and supervisord run as the unprivileged nobody user, and logs from all services are sent to the container output for docker logs.

The repository is intended as a readable example of running Nginx and PHP-FPM in a container. Guides cover adding Xdebug, Composer, real client IP handling behind a load balancer, and sending email.

Key features

  • 01Runs PHP-FPM 8.5 and Nginx 1.28 on Alpine Linux in a small image of about 40MB.
  • 02Supports AMD64, ARMv6, ARMv7 and ARM64 platforms.
  • 03Uses PHP-FPM's on-demand process manager to consume resources only under traffic.
  • 04Runs Nginx, PHP-FPM and supervisord as the unprivileged nobody user.
  • 05Sends logs from all services to the container output.
  • 06Allows Nginx, PHP and PHP-FPM settings to be overridden by mounting config files.

Use cases

  • Serving a PHP application in a container without building a custom web server image.
  • Running PHP sites on low-power ARM devices such as Raspberry Pi boards.
  • Using a minimal PHP base image as a starting point for a customized Docker setup.
  • Learning how Nginx and PHP-FPM are wired together in a container.

Quick start

  1. 1

    Start the container with Docker

    docker run -p 80:8080 trafex/php-nginx
  2. 2

    Mount your own code to serve it with PHP-FPM and Nginx

    docker run -p 80:8080 -v ~/my-codebase:/var/www/html trafex/php-nginx

Things to know

  • Image is a minimal example and is configured for Alpine's PHP 8.5 and Nginx 1.28 packages only.
  • Customizing configuration requires mounting your own config files into the container.

Topics

FAQ

What is docker-php-nginx?
A small Alpine Linux Docker image that runs PHP-FPM 8.5 and Nginx together, serving PHP apps out of the box. This project is a Docker image that packages PHP-FPM 8.5 and Nginx 1.28 on Alpine Linux, so you can serve PHP applications without assembling the web server stack yourself. Mounting your code into /var/www/html is enough to start serving it, and configuration files for Nginx, PHP and PHP-FPM can be overridden with volume mounts.
Is docker-php-nginx free to use? What license does it have?
docker-php-nginx is open source under the MIT license. Check the license terms before using it in commercial products.
Is docker-php-nginx still maintained?
Actively maintained. The last commit to docker-php-nginx was on Oct 31, 2026.
What can I use docker-php-nginx for?
Serving a PHP application in a container without building a custom web server image. Running PHP sites on low-power ARM devices such as Raspberry Pi boards. Using a minimal PHP base image as a starting point for a customized Docker setup. Learning how Nginx and PHP-FPM are wired together in a container.
How do I install docker-php-nginx?
Start the container with Docker: docker run -p 80:8080 trafex/php-nginx Mount your own code to serve it with PHP-FPM and Nginx: docker run -p 80:8080 -v ~/my-codebase:/var/www/html trafex/php-nginx
Where can I get docker-php-nginx?
The source code and installation instructions are on GitHub: https://github.com/TrafeX/docker-php-nginx

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects