之前帮客户整了一套基于GeoIP2的自动化AB站(Nginx Geoip2 处理不同国家 (或城市) 的访问
),客户最近想通过管理端手动控制AB站切换
创建独立片段nginx配置文件,例如ar414.conf,然后在nginx vhost中include
ar414.conf
root /www/wwwroot/ahost;
site.conf
server { listen 80; server_name 0.0.0.0; index index.html; include /www/wwwroot/abhost/ar414.conf; }
if($data['site_set'] == AbHostSiteEnum::Ahost) { //开启A站 $ahostPath = AbHostSiteEnum::AhostPath; file_put_contents('./ar414.conf',"root {$ahostPath};");}else { //开启B站 $bhostPath = AbHostSiteEnum::BhostPath; file_put_contents('./ar414.conf',"root {$bhostPath};");}
30s内Nginx无法平滑退出,就强行关闭进程
nginx.conf
...worker_shutdown_timeout 30;
crontab -e
立即学习“PHP免费学习笔记(深入)”;
*/5 * * * * nginx -s reload
推荐教程:《PHP》
以上就是PHP Web 端如何操作 Nginx 配置的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号