mac搭建docker lnmp环境

记录下创建步骤

1、docker run -d --name myFpm -p 9000:9000 -v ~/DockerApp/docker-lnmp/app/src:/usr/share/nginx/html php:7.0.5-fpm

2、docker run -d --name myNginx -p 80:80 -v ~/DockerApp/docker-lnmp/app/src:/usr/share/nginx/html nginx

3、docker inspect myFpm | grep "IPAddress"  得到fpm虚拟机ip 172.17.0.2

4、vim docker-lnmp/nginx/conf.d/default.conf   

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;
    }

5、cd docker-lnmp/nginx/conf.d/

6、docker cp ./default.conf myNginx:/etc/nginx/conf.d/default.conf

7、docker exec -it myNginx bash

8、service nginx reload

9、control+p+q退出容器(该快捷键只退出容器,而容器进程不退出)

10、访问127.0.0.1/index.php  成功看到phpinfo信息

你可能感兴趣的:(技术)