账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    docker-compose中nginx无法连接到 php提示not found in upstream php-fpm ?
    30
    0

    环境:centos7+docker17.12+docker-compose1.8.0
    yml文件

    mysql5.7+php7.2+nginx1.13 均是官方下载的镜像,版本为latest

    version: "3"
    services:
        php-fpm:
          image: php:latest
          restart: always
          links:
            - mysqldb:mysqldb
          volumes:
            - "./src:/var/www/html"
          expose:
            - 9000
    
        nginx:
          image: nginx:latest
          restart: always
          depends_on:
            - php-fpm
            - mysqldb
          links:
            - php-fpm
          volumes:
            - "./src:/usr/share/nginx/html"
            - "./nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf"
          ports:
              - "8888:80"
    
        mysqldb:
          image: mysql:latest
          restart: always
          volumes:
            - "./data:/var/lib/mysql"
          ports:
            - "3306:3306"
          environment:
            MYSQL_USER: root
            MYSQL_PASSWORD: 123456
            MYSQL_ROOT_PASSWORD: 123456
    

    nginx配置如下default.conf

    server {
      listen    80;
      server_name localhost;
      
      #charset koi8-r;
      
      #access_log logs/host.access.log main;
      
      location / {
        root  html;
        index index.html 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  html;
      }
      
      # proxy the PHP scripts to Apache listening on 127.0.0.1:80
      #
      #location ~ \.php$ {
      #  proxy_pass  http://127.0.0.1;
      #}
      
      location ~ [^/]\.php(/|$) {
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        fastcgi_pass php-fpm:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        include fastcgi_params;
      }
      
      # deny access to .htaccess files, if Apache's document root
      # concurs with nginx's one
      #
      #location ~ /\.ht {
      #  deny all;
      #}
    }
    
    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • 茉莉花、 普通会员 1楼
      { "error": "Failed to generate content." }
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部