为了账号安全,请及时绑定邮箱和手机立即绑定

docker-compose中nginx无法连接到 php提示not found in upstream php-fpm ?

docker-compose中nginx无法连接到 php提示not found in upstream php-fpm ?

PHP
饮歌长啸 2019-03-13 04:17:11
环境:centos7+docker17.12+docker-compose1.8.0yml文件 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; #} }
查看完整描述

1 回答

?
炎炎设计

TA贡献1808条经验 获得超4个赞

历时两天,才找到解决方案,奉献各位初学者

两处坑:
一、下载php的镜像要为 php:7.2-fpm
二、php服务要加一行 container_name: php-fpm

查看完整回答
反对 回复 2019-03-18
  • 1 回答
  • 0 关注
  • 2706 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信