环境:centos7+docker17.12+docker-compose1.8.0
yml文件
mysql5.7+php7.2+nginx1.13 均是官方下载的镜像,版本为latest
version: "3"
services:
php-fpm:
image: php:latest
restart: always
links:
- mysqldb:mysqldb
volumes:
- "./src:/var/www/html"
expose:
- 9000
nginx:
image: nginx:latest
restart: always
depends_on:
- php-fpm
- mysqldb
links:
- php-fpm
volumes:
- "./src:/usr/share/nginx/html"
- "./nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf"
ports:
- "8888:80"
mysqldb:
image: mysql:latest
restart: always
volumes:
- "./data:/var/lib/mysql"
ports:
- "3306:3306"
environment:
MYSQL_USER: root
MYSQL_PASSWORD: 123456
MYSQL_ROOT_PASSWORD: 123456
nginx配置如下default.conf
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html 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 html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass php-fpm:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
炎炎设计