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 镜像:
启动 php的时候加上 -v 参数,把本地路径挂到镜像里,比如把 laravel项目挂到 /var/www/laravel 路径下面
启动 nginx,
修改nginx镜像中的配置,
访问 localhost:8083