标签:说明 link 名称 pch imp oat scm word span
docker search nginx
docker pull nginx
docker run -d --name nginx -p 8080:80 -v /tmp:/usr/share/nginx/html docker.io/nginx
说明
在/tmp 目录下新建一个 index.html 里面打个 hello nginx
访问 127.0.0.1:8080 正确的情况下会出现该文件内容
docker search php-fpm
docker pull bitnami/php-fpm
4.运行 php-fpm
docker run -d -v /tmp:/usr/share/nginx/html --name php-fpm docker.io/bitnami/php-fpm
docker inspect php-fpm | grep "IPAddress"
#copy 配置文件
docker cp nginx:/etc/nginx/conf.d/default.conf ./default.conf
vim ./default.conf
#copy 下面的
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm 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 /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass 172.17.0.2:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache‘s document root
# concurs with nginx‘s one
#
#location ~ /\.ht {
# deny all;
#}
}
# 修改 fastcgi_pass 127.0.0.1:9000; 为:
# fastcgi_pass 172.17.0.2:9000;
# 其中 172.17.0.2 是 上面查看 IP 获取的 每次都不一样
#覆盖到 nginx
docker cp ./default.conf nginx:/etc/nginx/conf.d/default.conf
#重启 nginx
docker restart nginx
<?php
echo phpinfo();
进入容器
docker exec -it nginx /bin/bash
复制容器内的配置到宿主机器
docker cp nginx:/etc/nginx/conf.d/default.conf ./default.conf
复制宿主机器文件到容器
docker cp ./default.conf myNginx:/etc/nginx/conf.d/default.conf
docker 重启容器
docker restart nginx
停止所有容器
docker stop $(docker ps -a -q)
删除所有容器
docker rm $(docker ps -a -q)
使用 docker 搭建 nginx+php-fpm 环境 (两个独立镜像)
标签:说明 link 名称 pch imp oat scm word span
原文地址:https://www.cnblogs.com/wangmy/p/10441084.html