您的位置:首页 > 运维架构 > Docker

Docker在Windows下搭建Nginx+PHP环境

2020-06-06 05:38 85 查看

下载PHP镜像

docker pull php:5.6-fpm

下载Nginx镜像

docker pull nginx:latest

运行PHP容器

docker run --name  myphp-fpm -v ~/nginx/www:/www  -d php:5.6-fpm

创建文件及文件夹

cd %USERPROFILE%
md nginx\conf\conf.d
md nginx\www

在用户目录下添加/nginx/conf/conf.d/runoob-test-php.conf 文件,内容如下:

server {
listen       80;
server_name  localhost;

location / {
root   /usr/share/nginx/html;
index  index.html index.htm index.php;
}

error_page   500 502 503 504  /50x.html;
location = /50x.html {
root   /usr/share/nginx/html;
}

location ~ \.php$ {
fastcgi_pass   php:9000;
fastcgi_index  index.php;
fastcgi_param  SCRIPT_FILENAME  /www/$fastcgi_script_name;
include        fastcgi_params;
}
}

在用户目录下添加/nginx/www/test.php 文件,内容如下:

<?php
echo phpinfo();
?>

运行Nginx容器

docker run --name runoob-php-nginx -p 8083:80 -d  -v ~/nginx/www:/usr/share/nginx/html:ro  -v ~/nginx/conf/conf.d:/etc/nginx/conf.d:ro  --link myphp-fpm:php nginx

测试结果

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: