Skip to content

Instantly share code, notes, and snippets.

@mapsi
Forked from wojas/docker-compose.yml
Created July 29, 2017 03:44
Show Gist options
  • Save mapsi/c0e71cdca327d2a542099272924410ae to your computer and use it in GitHub Desktop.
Save mapsi/c0e71cdca327d2a542099272924410ae to your computer and use it in GitHub Desktop.
docker-compose for nginx with php5-fpm using small alpine images
version: '2'
services:
php:
image: php:5.6-fpm-alpine
volumes:
- data:/_data
- ./site:/var/www/html:ro
networks:
- backend
command: sh -c 'chown www-data /_data && exec php-fpm'
nginx:
image: nginx:stable-alpine
volumes:
- ./site:/var/www/html:ro
- ./nginx.conf:/etc/nginx/nginx.conf:ro
ports:
- "8000:80"
networks:
- backend
networks:
backend:
volumes:
data:
driver: local
user nginx;
worker_processes 1;
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 /dev/stdout main;
#sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
gzip on;
server {
listen 80;
server_name example.com;
location / {
root /var/www/html;
index index.php;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
root html;
fastcgi_pass php:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/html/$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
location ~ /\.ht {
deny all;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment