-
先下载nginx镜像,php镜像
docker pull nginx
docker pull php:7.1.30-fpm
-
运行 php容器
docker run --name php71 -p 9000:9000 -d php:7.1.30-fpm
-
然后运行nginx 主要是nginx 的配置文件需要修改下
server { listen 8080; listen [::]:8080; server_name localhost; index index.html index.htm index.php; root /usr/share/nginx/html; location ~ \.php$ { fastcgi_pass php71:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } 其中fastcgi_pss 后面是你运行将要运行nginx的时候给php71起的别名,当然我们 可以设置成一样的,$document_root是上 面root定 义的根目录.如果浏览器访问的是 一个html文件,则不需要进入php71沙箱,直接在nginx沙箱中找/usr/share/nginx/html 找文件.如果访问的是php文件,则需要进入php71沙箱,然后定位到/usr/share/nginx/html 这个目录查找文件.所以最好的方法需要保证两个沙箱都该/usr/share/nginx/html目录
-
运行nginx文件 即可
docker run --name nginx-test -p 80:8080 -d -v /etc/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf -v /etc/nginx/nginx.conf:/etc/nginx/nginx.conf -v /usr/share/nginx/html/:/usr/share/nginx/html --link php71:php71 nginx:2.0
–link 容器名字:容器在nginx-test的别名,这里都是php71
docker安装php并调试ngixn
最新推荐文章于 2023-07-02 10:10:12 发布