如何在网络应用程序中进行 A/B 切换? (用于部署更新)
我目前有一个指向 /public_html/ 的 mysite.com (A) 和一个指向 /public_html/ 的 dev.mysite.com (B),我为此创建了一个 /dev_html/ 。我克隆了该网站,但现在我需要一种在它们之间切换的方法,而不必将所有文件从一个目录复制到另一个目录,也不必关闭该网站。我只想将直播站点切换到B,然后在A上工作,完成后将直播站点切换到A并在B上工作。有没有简单的方法?我正在使用 cPanel X 和 cPanel 11 (WHM VPS)。此外,两者都可以与同一个数据库交互,因此这不是问题,因为我没有更改任何数据库结构。只有php/js/img文件需要切换。
I currently have a mysite.com (A) which points to /public_html/ and a dev.mysite.com (B) which I created a /dev_html/ for that. I cloned the site but now I need a way of switching between them without having to copy all the files from one dir to another and without bringing the site down. I just want to switch the live site to B and then work on A, and when I finish, switch the live site to A and work on B. Is there a simple way? I'm using cPanel X and cPanel 11 (WHM VPS). Also, both can interact with the same database so that's not an issue as I'm not changing any database structure. Only the php/js/img files need to switch.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不确定您是否有选项将域、子域映射到 CPANEL 中的文件夹,因为我不是 cpanel 的忠实粉丝。我使用的托管公司允许将文件夹映射到我创建的域和子域,因此我也有两个文件夹。
我的一个文件夹是 v1,另一个文件夹是 v2。
当我对 v2 中的版本进行增强时,我将实时域指向 v1,而当我必须对 v1 进行增强时,我将域指向 v2(但是当发生切换时,无论如何我都必须复制文件 - 优点是 beta当我复制而不是主网站时,网站抛出错误)
Not sure if you have options to map domains, sub domains to folders in CPANEL as Im not a huge cpanel fan. The hosting company that I use allows mapping folders to domains and subdomains that I create so I have two folders too.
One of my folders in v1 and other folder is v2.
I point the live domain to v1 when Im working on enhancements on the version in v2 and point the domain to v2 when I have to do enhancements on v1 (but when switch happens I have to copy the files anyway- the advantage is that the beta website throws errors while Im copying over and not the main website)
vhost 文件
编辑您的 vhosts 文件以指向其他目录。
目前,您将有一个容器,声明站点文件位于 public_html
将其更改为 dev_html 并运行以下命令以查看是否一切正常。
如果没有错误,运行
vhost file
Edit your vhosts file to point to the other directory.
Currently you will have a container that states that the site files are located at public_html
Change that to dev_html and run the following command to see if it all went ok.
If there are no errors, run