您如何将网站部署到您的网络服务器?
在我的公司,我们有 8 位 Web 开发人员,负责我们的商业网站(完全用 PHP 编写,但这无关紧要).小组中的每个人都同时从事不同的项目,每当他们完成任务时,他们就会立即部署它(因为现在业务发展很快).
At my company we have a group of 8 web developers for our business web site (entirely written in PHP, but that shouldn't matter). Everyone in the group is working on different projects at the same time and whenever they're done with their task, they immediately deploy it (cause business is moving fast these days).
目前,开发工作在一个共享服务器上进行,所有开发人员都在同一个代码库上工作(使用 RCS 将文件与其他人锁定").当部署到期时,更改的文件被复制到暂存"服务器,然后同步脚本将文件上传到我们的主网络服务器,然后从那里分发到其他 9 个服务器.
Currently the development happens on one shared server with all developers working on the same code base (using RCS to "lock" files away from others). When deployment is due, the changed files are copied over to a "staging" server and then a sync script uploads the files to our main webserver from where it is distributed over to the other 9 servers.
很高兴,web 开发团队向我们寻求帮助以改进流程(在我们抱怨了一段时间之后),现在我们设置他们的开发环境的想法如下:
Quite happily, the web dev team asked us for help in order to improve the process (after us complaining for a while) and now our idea for setting up their dev environment is as follows:
- 具有虚拟目录的开发服务器,因此每个人都有自己的代码库,
- 用于跟踪更改的 SVN(或任何其他 VCS)
- 用于测试保持最新签入代码的中央服务器
现在的问题是:我们如何设法将更改的文件部署到服务器上,而不会意外上传其他项目的错误?我的第一个想法是简单地从存储库中导出最新版本,但这并不能完全控制文件.
The question is now: How do we manage to deploy the changed files on to the server without accidentaly uploading bugs from other projects? My first idea was to simply export the latest revision from the repository, but that would not give full control over the files.
你是如何处理这种情况的?你有什么样的部署脚本?
How do you manage such a situation? What kind of deployment scripts do you have in action?
(作为一个特殊的挑战:网站在过去 10 年里有机地增长,所以项目没有分成小块,而是一个特定功能的文件分布在整个目录树中.)
(As a special challenge: the website has organically grown over the last 10 years, so the projects are not split up in small chunks, but files for one specific feature are spread all over the directory tree.)
推荐答案
Cassy - 显然,要使源代码管理完全有序,您还有很长的路要走,但听起来您已经在路上了!
Cassy - you obviously have a long way to go before you'll get your source code management entirely in order, but it sounds like you are on your way!
拥有单独的沙箱肯定会有所帮助.接下来,请确保该网站始终只是从 Subversion 中对特定修订版、标签或分支的干净检出.
Having individual sandboxes will definitely help on things. Next then make sure that the website is ALWAYS just a clean checkout of a particular revision, tag or branch from subversion.
我们使用 git,但我们有类似的设置.我们用版本号标记特定版本(在 git 中,我们还可以向标记添加描述;适用于发布说明!)然后我们有一个脚本,任何有权访问发布"的人都可以运行该脚本需要两个参数 -- 将要更新的系统(数据中心,如果我们要更新测试或生产服务器),然后是版本号(标签).
We use git, but we have a similar setup. We tag a particular version with a version number (in git we also get to add a description to the tag; good for release notes!) and then we have a script that anyone with access to "do a release" can run that takes two parameters -- which system is going to be updated (the datacenter and if we're updating the test or the production server) and then the version number (the tag).
脚本使用 sudo 然后在共享帐户中运行发布脚本.它检查相关版本,最小化 javascript 和 CSS1,将代码推送到相关服务器以供环境,然后重新启动需要重新启动的内容.发布脚本的最后一行连接到其中一个网络服务器并跟踪错误日志.
The script uses sudo to then run the release script in a shared account. It does a checkout of the relevant version, minimizes javascript and CSS1, pushes the code to the relevant servers for the environment and then restarts what needs to be restarted. The last line of the release script connects to one of the webservers and tails the error log.
在 我们的 网站 我们在每个页面的底部包含了一个带有当前服务器名称和版本的 html 注释 - 可以很容易地看到现在正在运行什么?"
On our websites we include an html comment at the bottom of each page with the current server name and the version -- makes it easy to see "What's running right now?"
1 和一堆其他类似的家务任务......
1 and a bunch of other housekeeping tasks like that...
相关文章