dszn2485 2016-06-16 19:38
浏览 158

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

Hello for my work I am doing a nginx server and php fpm server with docker, but I do not know how to link nginx and php with fast cgi

Nginx - Docker file

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 "
daemon 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

What is being returned:

File not found.

Thanks for your help!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 #MATLAB仿真#车辆换道路径规划
    • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
    • ¥15 数据可视化Python
    • ¥15 要给毕业设计添加扫码登录的功能!!有偿
    • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
    • ¥15 微信公众号自制会员卡没有收款渠道啊
    • ¥100 Jenkins自动化部署—悬赏100元
    • ¥15 关于#python#的问题:求帮写python代码
    • ¥20 MATLAB画图图形出现上下震荡的线条
    • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘