Last active
January 10, 2021 01:11
-
-
Save vonKrafft/5fd248c438711148be878683f6f58b0f to your computer and use it in GitHub Desktop.
Un simple site en PHP avec Docker et Nginx (https://vonkrafft.fr/console/simple-site-php-avec-docker-nginx/)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
web-nginx: | |
image: nginx:stable-alpine | |
container_name: web-nginx | |
volumes: | |
- "./docker-web/www:/usr/share/nginx/html:ro" | |
- "./docker-web/log:/var/log/nginx" | |
- "./docker-web/nginx.conf:/etc/nginx/nginx.conf:ro" | |
ports: | |
- "127.0.0.1:80:80" | |
web-php: | |
image: php:fpm-alpine | |
container_name: web-php | |
volumes: | |
- "./docker-web/www:/script:ro" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user nginx; | |
worker_processes 1; | |
error_log /var/log/nginx/error.log warn; | |
pid /var/run/nginx.pid; | |
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; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usefull, thanks you.