Mercurial - 保持部署和开发存储库

发布于 2024-09-11 00:36:35 字数 1074 浏览 4 评论 0原文

我正在开发一个 PHP 网站,我刚刚添加了一个开关来决定它运行的环境 - 当它在我的本地站点上运行时使用 development ,当它在我的本地站点上运行时添加 product 。它在网络主机上实时运行:

<?php
define('ENV','development');
//or
define('ENV','production');

我在带有 Mercurial 的 VC 下拥有该站点,并且通常只需使用 hg Push 部署我的站点(服务器也运行 hg),但是,添加了此开关,“生产”站点始终与“开发”站点不同,因为实时部署的版本将始终设置为生产而不是开发

这意味着我的部署过程从

  1. 开发
  2. 测试
  3. hg commit -m "Madechanges"
  4. hg Push
  5. ssh host hg update
  6. 转到 1.

  1. 开发
  2. 测试
  3. hg commit -m "Made Changes"
  4. development 更改为 生产
  5. `hg commit -m "dev -> prod"
  6. hg推送
  7. ssh主机hg更新
  8. (稍后:)更改生产 -> development
  9. hg commit -m "prod -> dev"
  10. 转到 1。

这显然不太好。

有没有某种方法可以使一个站点与另一个站点隔离,以便实时站点始终设置为生产,而我的本地副本设置为开发

I am working on a PHP website where I have just added a switch for what environment it is running in - development for when it is running on my local site, and production when it is running live on the web host:

<?php
define('ENV','development');
//or
define('ENV','production');

I have the site under VC with Mercurial, and usually simply deploy my site with hg push (the server runs hg too), however, with the addition of this switch, the "production" site will always differ from the "development" site in that the version deployed live will always be set to production instead of development.

This means my deployment process goes from

  1. Develop
  2. Test
  3. hg commit -m "Made changes"
  4. hg push
  5. ssh host hg update
  6. Go to 1.

to

  1. Develop
  2. Test
  3. hg commit -m "Made changes"
  4. Change development to production
  5. `hg commit -m "dev -> prod"
  6. hg push
  7. ssh host hg update
  8. (later:) Change production -> development
  9. hg commit -m "prod -> dev"
  10. Go to 1.

Which is obviously not great.

Is there some way to keep one insulated from the other, so that the live site will always be set to production and my local copy set to development?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

小巷里的女流氓 2024-09-18 00:36:35

不使用交换机,而是使用开发分支和生产分支。

hg up prodbranch 
hg merge -r devbranch
hg push
ssh yourserver hg update prodbranch

Instead of having a switch, have a development branch and a production branch.

hg up prodbranch 
hg merge -r devbranch
hg push
ssh yourserver hg update prodbranch
明明#如月 2024-09-18 00:36:35

如果你有一个 Apache Web 服务器,你可以在 server/vhost/per-directory/.htaccess 配置中设置它:

SetEnv Deployment development

或者在生产中

SetEnv Deployment production

并且在你的脚本使用中:

define('ENV',$_ENV['Deployment'])

我假设(通常是)实际的 Web 服务器/虚拟主机配置是正常代码之外。

http://httpd.apache.org/docs/2.2/mod/ mod_env.html#setenv

If you have an Apache webserver, you could just set this in server/vhost/per-directory/.htaccess config:

SetEnv Deployment development

Or in production

SetEnv Deployment production

And in your script use:

define('ENV',$_ENV['Deployment'])

I assume (as it usually is) that the actual webserver / virtualhost config is outside the normal code.

http://httpd.apache.org/docs/2.2/mod/mod_env.html#setenv

岁月静好 2024-09-18 00:36:35

您是否考虑过不将配置文件置于版本控制之下?

Have you thought about just not putting your conifguration file under version control?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文