在SVN部署期间保持dev和live环境之间的配置差异 [英] maintaining configuration differences between dev and live environments during deployment from SVN

查看:210
本文介绍了在SVN部署期间保持dev和live环境之间的配置差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用ExpressionEngine CMS(php)来创建网站。对于每个站点,我们设置了一个subversion存储库并提交EE安装以及所使用的任何自定义模板,图像,javascript等。包含在仓库中的是包含所有环境变量和.htaccess文件的文件。

We use the ExpressionEngine CMS (php) to create websites. For each site, we set up a subversion repository and commit the EE installation as well as any custom templates, images, javascript, etc. that are used. Included in the repository is the file containing all of the environment variables and the .htaccess file.

我们有一个开发服务器,承诺我们用于开发。当我们准备发布时,我们在subversion中创建一个分支,进行生产环境所需的任何更改,标记版本号,导出存储库,将其上传到活动服务器上的新目录,并将文件符号链接到位。回滚非常简单,只需要回到上一个版本即可。

We have a development server with a working copy of the repository updated via post-commit that we use to develop. When we are ready to release we create a branch in subversion, make any changes required for the production environment, tag the release number, export the repository, upload it to a new directory on the live server, and symlink the files into place. A rollback is as simple as symlinking back to the previous release.

问题是,我们必须修改环境变量,生产服务器。这是东西喜欢(不)注释htaccess规则,将重定向到错误的地方,换出谷歌地图API密钥,因为域是不同的,运行脚本,将JavaScript最小化到一个模糊文件,以保持大小和http连接关闭等。

The problem is that step where we have to modify the environment variables that need to be different for the dev and production servers. This is stuff like (un)commenting htaccess rules that would redirect to the wrong places, swapping out google map API keys because the domains are different, running scripts that minimize the javascript into one obfuscated file to keep the size and http connections down, etc.

问题是如何更自动化?我们希望将发布过程降至最低限度。我熟悉存在的工具,如Capistrano和Make,但我不知道如何我可以让他们修改所有必要的文件...你将如何组织这样的事情?这是值得花时间自动化,当它发生也许每两个星期一次?

The question is how could this be more automated? We would love to get the release procedure down to the bare minimum. I'm familiar with the existence of tools such as Capistrano and Make but I'm not sure how I could get them to modify all the files necessary... how would you organize such a thing? Is this worth spending time automating when it happens maybe once every couple of weeks?

推荐答案

很多配置选项可以处理通过打开$ _SERVER ['HTTP_HOST']。

A lot of the configuration options could be dealt with by switching on $_SERVER['HTTP_HOST'].

例如

switch ($_SERVER['HTTP_HOST']) {
    case 'developement.domain.com':
        $api_key = "dev environment api key";
        break;
    default:
        $api_key = "live environment api key";
}

然后对于.htaccess问题,您可以在vhost中设置一个备用的.htaccess文件使用AccessFileName指令定义:

Then for .htaccess issues you can set an alternate .htaccess file in your vhost definition using the AccessFileName directive:

<VirtualHost *:80>
    ServerName sitename
    AccessFileName .htaccess-dev
</VirtualHost>

这篇关于在SVN部署期间保持dev和live环境之间的配置差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆