laravel 如何在docker上诊断404未找到错误nginx?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40058495/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to diagnose 404 not found error nginx on docker?
提问by koalaok
I'm trying to make working out laradock (docker+laravel) following: https://github.com/LaraDock/laradockinstructions
我正在尝试按照以下方式解决 laradock (docker+laravel):https: //github.com/LaraDock/laradock说明
I installed docker + cloned laradock.git laradock folder is located at /myHD/...path../www/laradock at the same level I have my laravel projects /myHD/...path../www/project01
我安装了 docker + 克隆的 laradock.git laradock 文件夹位于 /myHD/...path../www/laradock 在同一级别我有我的 Laravel 项目 /myHD/...path../www/project01
I edited laradock/docker-compose.xml
我编辑了 laradock/docker-compose.xml
### Laravel Application Code Container ######################
volumes_source:
image: tianon/true
volumes:
- ../project01/:/var/www/laravel
After this, bu I'm not sure it this is how to reload correctly after editing docker-file, I did:
在此之后,我不确定这是编辑 docker-file 后如何正确重新加载,我做了:
docker-compose up -d nginx mysql
now since I have a nginx error 404 not found: how can I debug the problem ?
现在,因为我找不到 nginx 错误 404:我该如何调试问题?
Additional info:
附加信息:
I entered the machine via bash:
我通过 bash 进入机器:
docker-compose exec --user=laradock workspace bash
but I cant find
但我找不到
/etc/nginx/... path (nginx folder doesn't exists !?!?)
回答by dev_a.y
Guessing your nginx is not located in the workspace container, it resides on a separate container, You've executed the following:
docker-compose up -d nginx mysql
猜测您的 nginx 不在工作区容器中,它驻留在单独的容器中,您已执行以下操作:
docker-compose up -d nginx mysql
That would probably only run nginx and mysql containers, not your php-fpm container. Also the path to you volume is important as the configurations in you nginx server depends on this.
那可能只会运行 nginx 和 mysql 容器,而不是你的 php-fpm 容器。此外,卷的路径也很重要,因为 nginx 服务器中的配置取决于此。
To run php-fpm, add php-fpm or something similar to the docker-compose up command, check out what this is called in your docker-compose.yaml file e.gdocker-compose up -d nginx mysql phpfpm
要运行 php-fpm,请添加 php-fpm 或类似于 docker-compose up 命令的内容,查看 docker-compose.yaml 文件中的名称,例如docker-compose up -d nginx mysql phpfpm
To assess you nginx container first of all execute
首先评估你的nginx容器执行
`docker ps -a`
From the list, look for the ID of your nginx container, before running
在运行之前,从列表中查找 nginx 容器的 ID
docker exec -it <container-id> bash
This should then give you assess to your nginx container to make the required changes.
这应该让您评估您的 nginx 容器以进行所需的更改。
Or without directly accessing the container, simply make changes in the nginx configuration file, look for 'server' and the 'root' change the root from var/www/laravel/public
to the new directory /project01/public
.
或者不直接访问容器,只需在 nginx 配置文件中进行更改,查找 'server' 和 'root' 将根var/www/laravel/public
从新目录更改为新目录 /project01/public
。
Execute the command to bring down your containers
执行命令来关闭你的容器
docker-composer down
Star over again with
再次与
docker-compose up -d nginx mysql phpfpm
Give it a go
搏一搏