Mercurial - 保持部署和开发存储库
我正在开发一个 PHP 网站,我刚刚添加了一个开关来决定它运行的环境 - 当它在我的本地站点上运行时使用 development
,当它在我的本地站点上运行时添加 product
。它在网络主机上实时运行:
<?php
define('ENV','development');
//or
define('ENV','production');
我在带有 Mercurial 的 VC 下拥有该站点,并且通常只需使用 hg Push
部署我的站点(服务器也运行 hg),但是,添加了此开关,“生产”站点始终与“开发”站点不同,因为实时部署的版本将始终设置为生产
而不是开发
。
这意味着我的部署过程从
- 开发
- 测试
hg commit -m "Madechanges"
hg Push
ssh host hg update
- 转到 1.
到
- 开发
- 测试
hg commit -m "Made Changes"
- 将
development
更改为生产
- `hg commit -m "dev -> prod"
hg推送
ssh主机hg更新
- (稍后:)更改
生产
->development
hg commit -m "prod -> dev"
- 转到 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
- Develop
- Test
hg commit -m "Made changes"
hg push
ssh host hg update
- Go to 1.
to
- Develop
- Test
hg commit -m "Made changes"
- Change
development
toproduction
- `hg commit -m "dev -> prod"
hg push
ssh host hg update
- (later:) Change
production
->development
hg commit -m "prod -> dev"
- 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不使用交换机,而是使用开发分支和生产分支。
Instead of having a switch, have a development branch and a production branch.
如果你有一个 Apache Web 服务器,你可以在 server/vhost/per-directory/.htaccess 配置中设置它:
或者在生产中
并且在你的脚本使用中:
我假设(通常是)实际的 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:
Or in production
And in your script use:
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
您是否考虑过不将配置文件置于版本控制之下?
Have you thought about just not putting your conifguration file under version control?