This is a simple Docker image to run CaddyServer with PHP-FPM.
The following examples use images that have already been built; you can build your own images as described below.
- Configure your Caddyfile and place it in a folder on your host. Exapmle:
{
email [email protected]
}
example.com:80 {
encode gzip
root * /www/websites
php_fastcgi localhost:9000
file_server
}
- Run the container with the following command. Example:
docker run -d -p 80:80 -p 443:443 -v /path/to/your/Caddyfile:/etc/caddy/Caddyfile -v /path/to/your/site:/www/websites --name caddyserver-php-fpm rainautos/caddyserver-php-fpmYou can use Docker Compose to run CaddyServer with PHP-FPM. For example:
- Configure your Caddyfile and Using the following command to create a container.
{
email [email protected]
}
example.com:80 {
encode gzip
root * /www/websites
# notice: php-fpm is the name of the container
php_fastcgi php-fpm:9000
file_server
}
version: '3'
services:
webservice:
container_name: caddy
image: caddy:latest
ports:
- "80:80"
- "443:443"
- "443:443/udp"
volumes:
- ${PWD}/Caddyfile:/etc/caddy/Caddyfile
- ${PWD}/config:/config
- ${PWD}/data:/data
- ${PWD}/websites:/www/websites
depends_on:
- php-cgi
restart: unless-stopped
networks:
- website
php-cgi:
container_name: php-fpm
build:
context: ./php-fpm/8.2
dockerfile: Dockerfile
volumes:
- ${PWD}/websites:/www/websites
restart: unless-stopped
networks:
- website
networks:
website:
driver: bridge```yaml
version: '3'
services:
webservice:
container_name: caddy
image: caddy:latest
ports:
- "80:80"
- "443:443"
- "443:443/udp"
volumes:
- /etc/localtime:/etc/localtime
- ${PWD}/Caddyfile:/etc/caddy/Caddyfile
- ${PWD}/opt/caddy/config:/config
- ${PWD}/opt/caddy/data:/data
- ${PWD}/websites:/www/websites
depends_on:
- php-cgi
restart: always
networks:
- website
php-cgi:
container_name: php-fpm
image: rainautos/php-fpm:8.1.15
volumes:
- /etc/localtime:/etc/localtime
- ${PWD}/websites:/www/websites
restart: always
networks:
- website
networks:
website:
driver: bridgeYou can find the Dockerfiles in the supervisor or php-fpm folder to build the images.
cd caddy-with-php/supervisor
docker build -t rainautos/caddyserver-php-fpm:latest .cd php-fpm/8.3
docker build -t rainautos/php-fpm:latest .