1、从多域名模式修改为单域名模式,修改了文件:frontend/config/main.php。如图1
2、从多域名模式修改为单域名模式,修改了文件:etc/nginx/conf.d/ccp_api.conf。如图2
3、现在计划在容器升级时,基于环境变量:CHANNEL_PUB_API_CFG_FRONTEND_DOMAIN_MODE=single|multiple。默认:single。可切换域名模式。
4、决定准备多域名下的两份文件,基于 shell 脚本,判断环境变量:CHANNEL_PUB_API_CFG_DOMAIN_NAME_MODE=multiple,执行文件拷贝。
5、编辑 shell 脚本,/config/init/config.sh。放在其他 shell 脚本之前。如图3
#!/bin/bash env | grep CHANNEL_PUB_API_CFG_FRONTEND_DOMAIN_MODE || export CHANNEL_PUB_API_CFG_FRONTEND_DOMAIN_MODE="single" if [[ $CHANNEL_PUB_API_CFG_FRONTEND_DOMAIN_MODE == "multiple" ]] then /cp /mcloud/ccp_api.conf /etc/nginx/conf.d/ chmod +x /etc/nginx/conf.d/* echo "前端的域名模式:多域名,复制 ccp_api.conf 至 /etc/nginx/conf.d/" /cp /mcloud/frontend/config/main.php /mcloud/www/ccp_api/frontend/config/ echo "前端的域名模式:多域名,复制 main.php 至 /mcloud/www/ccp_api/frontend/config/" elif [[ $CHANNEL_PUB_API_CFG_FRONTEND_DOMAIN_MODE == "single" ]] then echo "前端的域名模式:单域名" else echo "please set environment variable CHANNEL_PUB_API_CFG_FRONTEND_DOMAIN_MODE single or multiple" fi
6、Nginx 未启动。原因在于 config0.sh 先于 config.sh 执行。将 config.sh 重命名为 ccp_init.sh。
[root@07ca67a1f3c1 conf.d]# nginx -t nginx: [emerg] host not found in "CHANNEL_PUB_API_CFG_NGINX_AUTH_LISTEN" of the "listen" directive in /etc/nginx/conf.d/ccp_api.conf:2 nginx: configuration file /etc/nginx/nginx.conf test failed [root@07ca67a1f3c1 conf.d]#
7、Nginx 已启动。如图4
[root@b9b472c89102 /]# nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful [root@b9b472c89102 /]#
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/250576.html