Docker无法使用php-fpm容器链接nginx容器

时间:2016-06-16 19:38:21

标签: php nginx docker

你好我的工作我正在使用docker做一个nginx服务器和php fpm服务器,但是 我不知道如何用快速cgi链接nginx和php

Nginx - Docker文件

FROM debian:jessie
MAINTAINER Thomas Vidal <thomas-vidal@hotmail.com>

RUN apt-get update && apt-get upgrade
RUN apt-get install -y wget
RUN wget http://nginx.org/keys/nginx_signing.key && apt-key add nginx_signing.key
RUN apt-get update && apt-get install -y nginx
RUN echo "\ndaemon off;" >> /etc/nginx/nginx.conf

RUN ln -sf /etc/nginx/conf.d /site-conf
RUN ln -sf /var/www/html /www

VOLUME ["/site-conf", "/www"]

EXPOSE 80 443

CMD nginx

Nginx - default.conf

server {
    listen 80;
    index index.php index.html;
    server_name 192.168.99.100;
    root /www;

    error_log  /var/log/nginx/error.log;
    access_log /var/log/nginx/access.log;

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass 192.168.99.100:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

}

Nginx - index.php

<?php phpinfo(); ?>

Php-fpm - Dockerfile

FROM debian:jessie
MAINTAINER Thomas Vidal <thomas-vidal@hotmail.com>

RUN apt-get update && apt-get upgrade
RUN apt-get install -y php5-fpm php5-cli php5-mysql php5-curl php5-mcrypt php5-gd php5-redis

RUN sed -e 's#;daemonize = yes#daemonize = no#' -i /etc/php5/fpm/php-fpm.conf
RUN sed -e 's#listen = /var/run/php5-fpm.sock#listen = [::]:9000#g' -i /etc/php5/fpm/pool.d/www.conf

EXPOSE 9000

CMD php5-fpm

返回的是什么:

  

找不到档案。

感谢您的帮助!

0 个答案:

没有答案