一、docker-compose.yml
version: '3'
services:
mysql:
image: mysql:5.7
container_name: mysql5.7
environment:
MYSQL_ROOT_PASSWORD: abc123456
MYSQL_ROOT_USER: root
expose:
- "3306"
ports:
- "3306:3306"
restart: always
php56:
image: php:5.6-fpm
container_name: php-56
restart: always
depends_on:
- mysql
links:
- mysql5
networks:
- admin_nginx_php
volumes:
- "/Users/yuyu/data/nginx/www:/data/workspace/test"
nginx:
image: nginx:latest
restart: always
container_name: nginx-latest
ports:
- "80:80"
networks:
- admin_nginx_php
depends_on:
- php56
links:
- php56
volumes:
- "/Users/yuyu/data/nginx/www:/data/workspace/test"
- "/Users/yuyu/data/nginx/logs:/var/log/nginx/"
- "/Users/yuyu/data/nginx/conf.d/:/etc/nginx/conf.d/"
- "/Users/yuyu/data/nginx/conf/nginx.conf:/etc/nginx/nginx.conf"
networks:
admin_nginx_php:
driver: bridge
二、nginx配置
server {
listen 80;
server_name localhost;
root /data/workspace/test;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location ^~ /api {
rewrite ^/api/(.*) /api/$1;break;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-for $remote_addr;
proxy_pass http://192.168.1.106:9093;
}
location ~ \.php {
include fastcgi_params;
#fastcgi_pass 172.16.0.10:9000;
fastcgi_pass php56:9000;
fastcgi_index index.php;
fastcgi_param RUN_ENV 'dev';
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
#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 /usr/share/nginx/html;
}
}
~