Highly optimized, secure, and flexible PHP-Apache base image with Multi-Arch & Enterprise Hardening.
5.7K
A PHP-Apache image optimized for high performance, production-ready security, and architectural flexibility. Featuring full Multi-Arch support (AMD64 & ARM64), it runs seamlessly on standard servers as well as ARM-based environments like AWS Graviton or Raspberry Pi.
linux/amd64, linux/arm64).noto) to minimize runtime security risks.setcap) to allow the non-root user to securely bind to standard ports (80/443).remoteip module and auto-fetch utility for Cloudflare IP ranges to log actual visitor IPs.This image comes equipped with a comprehensive set of system utilities and PHP extensions:
ffmpeg, git, curl, zip, unzip, vim, poppler-utils (PDF to image conversions), openssl, jq.pdo_mysql, mysqli, pdo_pgsql, pgsql.gd (compiled with FreeType & JPEG support), imagick.ldap, memcached, mcrypt.intl, zip, gmp, bcmath, exif, gettext, opcache.Run the container using standard ports with the following command:
docker run -d --name app -e TZ=Asia/Jakarta -p 80:80 -p 443:443 tarnoto/php-apache:latest
services:
app:
image: tarnoto/php-apache:latest
ports:
- "80:80"
- "443:443"
environment:
- PHP_TIMEZONE=Asia/Jakarta
- PHP_MEMORY_LIMIT=512M
- PHP_DISPLAY_ERRORS=Off
If your application requires executing binary utilities like FFmpeg or Poppler-utils (pdftoppm) via PHP shell_exec(), you can easily unlock them by overriding the default environment variables in your docker-compose.yml:
environment:
- PHP_ALLOW_URL_FOPEN=On # Unlock external API fetching if needed
- PHP_DISABLE_FUNCTIONS=passthru,system,curl_multi_exec,parse_ini_file,show_source # Excluded shell_exec, exec, proc_open, popen from the blocklist
Customize your PHP & Apache configurations on the fly without rewriting or rebuilding the image:
| Variable | Default | Description |
|---|---|---|
TZ | Asia/Jakarta | Sets system & PHP global timezone |
PHP_TIMEZONE | Asia/Jakarta | Sets specific PHP script timezone |
PHP_MEMORY_LIMIT | 512M | Maximum memory limit per PHP script |
PHP_UPLOAD_MAX_FILESIZE | 50M | Maximum allowed size for uploaded files |
PHP_MAX_FILE_UPLOADS | 10 | Maximum number of simultaneous file uploads |
PHP_POST_MAX_SIZE | 100M | Maximum size of POST data allowed |
PHP_DISPLAY_ERRORS | Off | Controls error printing to the screen (On/Off) |
PHP_DISPLAY_STARTUP_ERRORS | On | Displays errors that occur during PHP startup sequence |
PHP_ERROR_REPORTING | E_ALL | Error reporting level (E_ALL records everything) |
PHP_MAX_EXECUTION_TIME | 60 | Maximum execution time of a script (in seconds) |
PHP_SESSION_MAXLIFETIME | 3600 | Session lifetime on the server (in seconds) |
PHP_ALLOW_URL_FOPEN | Off | Controls external URL fetching via file_get_contents() (On/Off) |
PHP_DISABLE_FUNCTIONS | exec,passthru, shell_exec,system, proc_open,popen, curl_multi_exec, parse_ini_file, show_source, proc_get_status, proc_terminate, chinit,chown, chgrp,chmod | Comma-separated list of dangerous PHP functions to block |
APACHE_DOCUMENT_ROOT | /var/www/public | Web root folder destination (Laravel/CI4 ready) |
TRUSTED_PROXY_IP | 10.0.0.0/8 | Space-separated Range of trusted upstream internal proxy network IPs |
HTTP_X_FRAME_OPTIONS | DENY | Clickjacking protection header configuration (DENY, SAMEORIGIN) |
HTTP_REFERRER_POLICY | strict-origin-when-cross-origin | Info leaks prevention (no-referrer, same-origin, etc.) |
COOKIE_SAMESITE | Strict | Session hijacking & CSRF mitigation (Strict, Lax, None) |
To deliver maximum framework compatibility and clean asset URLs, this image listens on native web ports while preserving strict container isolation:
Note: Secure low-port binding is handled internally via Linux kernel capabilities (cap_net_bind_service), keeping your deployment lightweight and resilient against privilege escalation.
The image automatically enforces hardened global HTTP Security Headers:
<iframe>.HttpOnly, Secure, and SameSite=Strict attributes to all cookies generated by PHP.Every time the container initializes, it executes an embedded routine to automatically pull and populate the latest Cloudflare IP ranges. If you deploy this image behind a Load Balancer, HAProxy, or an Nginx host reverse proxy, ensure your proxy injects the standard X-Forwarded-For header. You can easily whitelist additional upstream load balancer blocks by passing them through the TRUSTED_PROXY_IP variable.
Content type
Image
Digest
sha256:6776da266…
Size
481.6 MB
Last updated
14 days ago
docker pull tarnoto/php-apache