一、从官方pull了nginx和php7.3; 二、直接创建镜像并复制配置文件到本地;
cp myphp:/etc D:\docker\workspace\php\73\etc
...
三、创建容器:
docker run -dit --name myphp -p 9000:9000 -v D:\docker\workspace\php\73\etc:/etc -v D:\docker\workspace\php\73\usr:/usr -v D:\docker\workspace\www:/usr/share/nginx/html phpdockerio/php73-fpm
docker run --name mynginx -p 80:80 --privileged=true -v D:\docker\workspace\www:/usr/share/nginx/html -v D:\docker\workspace\nginx\conf.d:/etc/nginx/conf.d --link myphp:php -d nginx
四、配置文件修改
- 本地新增文件:D:\docker\workspace\nginx\conf.d\mynginx.conf
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
location ~ \.php$ {
fastcgi_pass php:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
五、访问 html、php
浏览器访问:http://localhost/index.html 没有问题, 浏览器访问:http://localhost/index.php 变成了下载index.php? 浏览器访问:http://localhost 访问的是index.html?
|