「解决」docker 运行laravel,nginx这样配置为何不可?
docker的nginx应该如何配置才可以运行项目。
本机电脑系统:mac
nginx配置如下如何修改
想要实现的效果:
将localhost:8083/yxfxs/public 访问laravel 改为 yxfxs.test即可访问
nginx配置:
server {
listen 80;
server_name localhost;
location / {
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?$query_string;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
fastcgi_pass php:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /www/$fastcgi_script_name;
include fastcgi_params;
}
}
hosts配置。如下:
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
127.0.0.1 content.test
127.0.0.1 AcronisDriveSearchPlugin
# Added by Docker Desktop
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
# End of section
laravel 项目目录:
docker 镜像:
hosts配置
这是 docker nginx 的配置
即可访问
考虑后面还要运行多个项目 就没有进行这个功能测试 有时间测试完这个东西再说吧。也欢迎大佬看到之后指正里面的问题或者直接回答关于去掉端口号的方法。
感谢风兮清扬提供的帮助