Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Un simple site en PHP avec Docker et Nginx (
mkdir -p docker-web/www # Webroot dans lequel sera stocké le contenu statique du site
mkdir -p docker-web/log # Pour enregistrer les journaux de Nginx
echo "<?php phpinfo();" > docker-web/www/index.php
docker-compose up -d
version: '3'
image: nginx:stable-alpine
container_name: web-nginx
- "./docker-web/www:/usr/share/nginx/html:ro"
- "./docker-web/log:/var/log/nginx"
- "./docker-web/nginx.conf:/etc/nginx/nginx.conf:ro"
- ""
image: php:fpm-alpine
container_name: web-php
- "./docker-web/www:/script:ro"
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/;
events {
worker_connections 1024;
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
server_tokens off;
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
location ~ \.php$ {
root /usr/share/nginx/html;
include fastcgi_params;
fastcgi_pass web-php:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /script$fastcgi_script_name;

This comment has been minimized.

Copy link

@antoineandrieu antoineandrieu commented Oct 16, 2019

Usefull, thanks you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.