Sign inSign up

chrno79/php-apache

By chrno79

Updated 7 months ago

A efficient web server sensible Apache defaults, and performance optimizations.

Image
Web servers
1

1.2K

chrno79/php-apache repository overview

PHP Docker Image (Optimized Trixie Builds)

This Docker image provides a efficient web server based on PHP 8.4 / 8.5 with Apache, designed to serve modern PHP applications in a production-ready Docker environment. It comes pre-configured with commonly used PHP extensions, sensible Apache defaults, and performance optimizations out of the box.

✅ Features

Base Image

Built on the official PHP 8.4 / 8.5 (Debian Trixie) image with Apache support, ensuring stability, security, and compatibility with modern PHP applications.

  • Pre-installed PHP Extensions
  • Includes essential extensions required by most PHP frameworks and applications:
  • mysqli – MySQL database interactions
  • pdo, pdo_mysql – PDO support for MySQL
  • gd – Image processing and manipulation
  • mbstring – Multibyte string functions
  • curl – URL handling and data transfer
  • xml – XML parsing and manipulation
  • zip – Zip archive handling
  • opcache – Opcode caching for performance improvements
  • bcmath – Arbitrary precision mathematics
  • intl – Internationalization support
  • exif – Image metadata handling
  • sockets – Low-level socket support
  • pcntl – Process control for CLI scripts
  • redis – PECL extension for Redis support

Apache Configuration

  • mod_rewrite enabled for clean URLs and SEO-friendly routing
  • mod_remoteip pre-configured to correctly handle real client IPs behind reverse proxies
  • Startup script automatically enables a mounted remoteip.conf if present

Hardened Apache defaults:

  • ServerTokens Prod
  • ServerSignature Off
  • TraceEnable Off
  • Production-ready PHP
  • Opcache enabled and tuned for performance
  • Increased memory and execution limits for large PHP applications
  • Optimized session handling and upload limits
  • Composer autoloader optimization at container startup (if composer.json exists)

🚀 Getting Started

Run the PHP 8.4 container

docker run -d --name webserver -p 80:80 chrno79/php-apache:latest

Run the PHP 8.5 container

docker run -d --name webserver -p 80:80 chrno79/php-apache:dev

Apache will be available on port 80.


📁 Volume Mapping

To serve your PHP application:

docker run -d --name webserver -p 80:80 \
  -v /path/to/your/php/files:/var/www/html \
  chrno79/php-apache:latest

Replace /path/to/your/php/files with the path to your PHP project.


🔧 Using RemoteIP (Reverse Proxy Support)

To forward the real client IP from a reverse proxy, create a remoteip.conf:

RemoteIPHeader X-Forwarded-For
RemoteIPTrustedProxy 172.18.0.0/16
RemoteIPTrustedProxy 172.19.0.0/24

Mount it into the container:

docker run -d --name webserver -p 80:80 \
  -v /path/to/remoteip.conf:/etc/apache2/conf-enabled/remoteip.conf:ro \
  -v /path/to/your/php/files:/var/www/html \
  chrno79/php-apache:latest

The configuration is automatically enabled at startup.

Nginx Proxy Manager example

proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;

🔧 Mount with custom php.ini

You can provide your own PHP configuration:

docker run -d --name webserver -p 80:80 \
  -v /path/to/remoteip.conf:/etc/apache2/conf-enabled/remoteip.conf:ro \
  -v /path/to/your/php/files:/var/www/html \
  -v /path/to/your/custom_php.ini:/usr/local/etc/php/php.ini
  chrno79/php-apache:latest

🤝 Contributing

Contributions are welcome! Fork the repository and submit pull requests for improvements, new features, or updated extensions.

Tag summary

Content type

Image

Digest

sha256:daf45d746

Size

396.4 MB

Last updated

7 months ago

docker pull chrno79/php-apache