gpt4 book ai didi

php - 简单的 Docker/Nginx 错误 - PHP/Laravel

转载 作者:行者123 更新时间:2023-12-02 20:46:56 25 4
gpt4 key购买 nike

我正在按照 this tutorial 构建一个 PHP 和 Laravel docker 多容器应用程序.

这很简单,我准确地遵循了它,但是在运行 docker-compose up 时遇到了以下错误:

database_1  | 2018-07-08 16:51:11 1 [Note] mysqld: ready for connections.
database_1 | Version: '5.6.40' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)
app_1 | [08-Jul-2018 15:02:52] NOTICE: fpm is running, pid 1
app_1 | [08-Jul-2018 16:51:10] NOTICE: ready to handle connections
web_1 | 2018/07/08 16:52:24 [emerg] 1#1: unknown directive "listen:" in /etc/nginx/conf.d/default.conf:2
web_1 | nginx: [emerg] unknown directive "listen:" in /etc/nginx/conf.d/default.conf:2
see-number_web_1 exited with code 1

以下是我的 web.dockerfile处理 web/nginx 服务:
FROM nginx:1.10

ADD vhost.conf /etc/nginx/conf.d/default.conf

这是 vhost.conf我正在使用的文件:
server {
listen 80;
index index.php index.html;
root /var/www/public;

location / {
try_files $uri /index.php?$args;
}

location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass app: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-compose.yml将它们保存在一起的文件:
version: '2'
services:

# The Application
app:
build:
context: ./
dockerfile: app.dockerfile
working_dir: /var/www
volumes:
- ./:/var/www
environment:
- "DB_PORT=3306"
- "DB_HOST=database"

# The Web Server
web:
build:
context: ./
dockerfile: web.dockerfile
working_dir: /var/www
volumes_from:
- app
ports:
- 8080:80

# The Database
database:
image: mysql:5.6
volumes:
- dbdata:/var/lib/mysql
environment:
- "MYSQL_DATABASE=homestead"
- "MYSQL_USER=homestead"
- "MYSQL_PASSWORD=secret"
- "MYSQL_ROOT_PASSWORD=secret"
ports:
- "33061:3306"

volumes:
dbdata:

我找到了 this StackOverflow answer谈论隐藏的 EOL 字符,但我尝试自己输入,并通过 this tool 运行它在同一个线程中。

关于为什么我可能会收到此错误的任何建议?

更新 1
根据要求,我包括 docker history对于导致问题的 Web 服务图像:
<user>:<project> <user>$ docker history see-number_web
IMAGE CREATED CREATED BY SIZE COMMENT
5c0285cb9dd2 6 hours ago /bin/sh -c #(nop) ADD file:4387275b028088cf9… 453B
0346349a1a64 15 months ago /bin/sh -c #(nop) CMD ["nginx" "-g" "daemon… 0B
<missing> 15 months ago /bin/sh -c #(nop) EXPOSE 443/tcp 80/tcp 0B
<missing> 15 months ago /bin/sh -c ln -sf /dev/stdout /var/log/nginx… 22B
<missing> 15 months ago /bin/sh -c apt-key adv --keyserver hkp://pgp… 58.2MB
<missing> 15 months ago /bin/sh -c #(nop) ENV NGINX_VERSION=1.10.3-… 0B
<missing> 15 months ago /bin/sh -c #(nop) MAINTAINER NGINX Docker M… 0B
<missing> 15 months ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0B
<missing> 15 months ago /bin/sh -c #(nop) ADD file:4eedf861fb567fffb… 123MB

最佳答案

因为它清楚地提示“/etc/nginx/conf.d/default.conf:2”中的“未知指令“listen:”。 nginx 容器配置中有问题。

为了更多地调试它,我会在 intractive 模式下手动运行 web_1 容器,并且应该开始查看/etc/nginx/conf.d/default.conf 文件。

否则,您只需重建您的 nginx 容器。

关于php - 简单的 Docker/Nginx 错误 - PHP/Laravel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51234277/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com