Install php7.2-fpm, nginx under Docker

Assuming docker is already installed

install php-fpm, nginx docker pull php:7.2-fpm docker pull nginx

Run: docker run --name a0e46664f823 -d -v /usr/local/etc/php/7.2/:/Users/kopa/Documents/docker/www/:ro php:7.2-fpm

Description: a0e46664f823 is the CONTAINER ID of the container, /usr/local/etc/php/7.2/ is the storage directory of local php files, /var/www/html is the storage directory of php files in the container, ro means read-only

run:

docker run --name kopa-nginx -p 80:80 -d -v /Users/kopa/Documents/docker/www:/usr/share/nginx/html:ro -v /Users/kopa/Documents/docker/nginx/conf.d:/etc/nginx/conf.d:ro --link php-fpm:php nginx

illustrate:

-p 80:80 用于添加端口映射,把 php-fpm 中的 80 端口暴露出来。
/Users/kopa/Documents/docker/www 是本地 html 文件的存储目录,/usr/share/nginx/html 是容器内 html 文件的存储目录。
/Users/kopa/Documents/docker/nginx/conf.d 是本地 nginx 配置文件的存储目录,/etc/nginx/conf.d 是容器内 nginx 配置文件的存储目录。
--link php-fpm:php 把 dream-php 的网络并入 kopa-nginx,并通过修改 kopa-nginx 的 /etc/hosts,把域名 php 映射成 127.0.0.1,让 nginx 通过 php:9000 访问 php-fpm。

Reference: https://segmentfault.com/a/1190000007056245

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325165060&siteId=291194637