- Dockerfile 82.1%
- PHP 17.9%
| public | ||
| compose.yaml | ||
| Dockerfile | ||
| README.md | ||
PHP Docker Environment
A Docker-based PHP development environment using FrankenPHP (a modern PHP server that combines Nginx and PHP-FPM into a single process) with Traefik reverse proxy integration.
Project Structure
php-docker/
├── Dockerfile # PHP container configuration
├── compose.yaml # Docker Compose service definition
├── README.md # This file
└── public/
└── index.php # Default PHP entry point
Components
Dockerfile
The Dockerfile is based on serversideup/php:8.5-frankenphp, which provides:
- PHP 8.5 - The latest PHP version
- FrankenPHP - A modern PHP server that integrates Nginx and PHP-FPM
- Pre-installed extensions - Ready for PHP development
Customizations:
- Installs the
intlandbcmathPHP extensions - Runs as
www-datauser for security
compose.yaml
The compose.yaml defines a single service:
| Feature | Configuration |
|---|---|
| Service Name | php |
| Port | localhost:8080 → container:8080 |
| Volume Mount | Current directory → /var/www/html |
| Network | proxy (Traefik integration) |
Traefik Labels
The service is configured for Traefik reverse proxy with:
- HTTP Router:
php.apps.actionbehind.com(port 80) - HTTPS Router:
php.apps.actionbehind.com(port 443) - HTTPS Redirect: Automatic redirect from HTTP to HTTPS
- SSL Certificate: Let's Encrypt certificate resolution
Prerequisites
- Docker
- Docker Compose (v2+)
- Traefik (for proxy functionality)
Usage Instructions
Quick Start
-
Start the container:
docker compose up -d -
Access the application:
- Local: http://localhost:8080
- Traefik: https://php.apps.actionbehind.com
-
View logs:
docker compose logs -f
Development
-
Place your PHP files in the public/ directory - This is the web root (
/var/www/html) -
Edit files locally - Changes are immediately reflected via volume mounting
-
Restart container after dependency changes:
docker compose up -d --build
Available PHP Extensions
The following extensions are pre-installed:
intl- Internationalization functionsbcmath- Arbitrary precision mathematics
Common Commands
| Command | Description |
|---|---|
docker compose up -d |
Start containers in background |
docker compose down |
Stop and remove containers |
docker compose down -v |
Stop, remove containers AND volumes |
docker compose logs -f |
Follow container logs |
docker compose exec php php -v |
Run PHP inside container |
docker compose exec php bash |
Get shell access to container |
Traefik Configuration Notes
The Traefik labels configure:
redirect-to-https@file- A Traefik middleware that redirects HTTP to HTTPScertresolver=letsencrypt- Uses Let's Encrypt for SSL certificates- Host rule - Routes requests to
php.apps.actionbehind.comto this service
If you're running locally without Traefik, you can access the service at http://localhost:8080 and ignore the Traefik labels.
Customization
To add more PHP extensions, modify the Dockerfile:
RUN install-php-extensions extension_name
To change the PHP version, update the base image:
FROM serversideup/php:8.2-frankenphp # or 8.3, 8.4
To modify Traefik configuration, update the labels section in compose.yaml.