简体   繁体   English

nginx:在 /etc/nginx/conf.d/nginx.conf:12 的上游“php”中找不到 [emerg] 主机

[英]nginx: [emerg] host not found in upstream "php" in /etc/nginx/conf.d/nginx.conf:12

docker-compose.yaml docker-compose.yaml

version: '3'
services:
  webserver:
    build:
      context: .
      dockerfile: Dockerfile.nginx
    ports:
      - '8000:80'
    image: nginx
    container_name: nginx_cont
    restart: unless-stopped
    volumes:
      - ./src:/var/www
      - ./nginx/conf.d:/etc/nginx/conf.d/
    depends_on:
      - app
  app:
    build:
      context: .
      dockerfile: Dockerfile.laravel
    image: laravel
    container_name: laravel_cont
    restart: unless-stopped
    volumes:
      - ./src:/var/www
      - ./src/config/php/local.ini:/usr/local/etc/php/conf.d/local.ini 

nginx.conf nginx.conf

server {
    listen 80;
    index index.php index.html;
    server_name localhost;
    root /var/www/public;
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass php:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
}

Docker.nginx Docker.nginx

FROM nginx:alpine

WORKDIR /etc/nginx/conf.d

COPY ./nginx/conf.d/nginx.conf /etc/nginx/conf.d/nginx.conf

COPY . /var/www

Running via docker-compose up and getting this error:通过 docker-compose 运行并出现此错误:

/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration nginx_cont | /docker-entrypoint.sh: /docker-entrypoint.d/ 不为空,将尝试执行配置 nginx_cont | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/ nginx_cont | /docker-entrypoint.sh:在 /docker-entrypoint.d/ nginx_cont 中寻找 shell 脚本 | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh nginx_cont | /docker-entrypoint.sh:启动 /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh nginx_cont | 10-listen-on-ipv6-by-default.sh: info: /etc/nginx/conf.d/default.conf is not a file or does not exist nginx_cont | 10-listen-on-ipv6-by-default.sh: info: /etc/nginx/conf.d/default.conf 不是文件或不存在 nginx_cont | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh nginx_cont | /docker-entrypoint.sh:启动 /docker-entrypoint.d/20-envsubst-on-templates.sh nginx_cont | /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh nginx_cont | /docker-entrypoint.sh:启动 /docker-entrypoint.d/30-tune-worker-processes.sh nginx_cont | /docker-entrypoint.sh: Configuration complete; /docker-entrypoint.sh:配置完成; ready for start up nginx_cont |准备启动 nginx_cont | 2022/06/07 11:25:24 [emerg] 1#1: host not found in upstream "php" in /etc/nginx/conf.d/nginx.conf:12 nginx_cont | 2022/06/07 11:25:24 [emerg] 1#1:在 /etc/nginx/conf.d/nginx.conf:12 的上游“php”中找不到主机nginx: [emerg] host not found in upstream "php" in /etc/nginx/conf.d/nginx.conf:12 nginx:在 /etc/nginx/conf.d/nginx.conf:12 的上游“php”中找不到 [emerg] 主机

     - ./src:/var/www/html:delegated

Try to replace the line on docker-compose.yaml with the above尝试用上面的替换docker-compose.yaml上的线

on the

volume

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM