php 自动部署 Web 应用程序?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45783/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Automate Deployment for Web Applications?
提问by Sam Wessel
My team is currently trying to automate the deployment of our .Net and PHP web applications. We want to streamline deployments, and to avoid the hassle and many of the headaches caused by doing it manually.
我的团队目前正在尝试自动部署我们的 .Net 和 PHP Web 应用程序。我们希望简化部署,并避免手动部署带来的麻烦和许多麻烦。
We require a solution that will enable us to:
我们需要一个解决方案,使我们能够:
- Compile the application
- Version the application with the SVN version number
- Backup the existing site
- Deploy to a web farm
All our apps are source controlled using SVN and our .Net apps use CruiseControl. We have been trying to use MSBuild and NAnt deployment scripts with limited success. We have also used Capistrano in the past, but wish to avoid using Ruby if possible.
我们所有的应用程序都使用 SVN 进行源代码控制,我们的 .Net 应用程序使用 CruiseControl。我们一直在尝试使用 MSBuild 和 NAnt 部署脚本,但收效甚微。我们过去也使用过 Capistrano,但希望尽可能避免使用 Ruby。
Are there any other deployment tools out there that would help us?
是否还有其他部署工具可以帮助我们?
采纳答案by Sam Wessel
Thank you all for your kind suggestions. We checked them all out, but after careful consideration we decided to roll our own with a combination of CruiseControl, NAnt, MSBuild and MSDeploy.
谢谢大家的好建议。我们检查了所有这些,但经过仔细考虑后,我们决定将 CruiseControl、NAnt、MSBuild 和 MSDeploy 结合起来推出我们自己的产品。
This article has some great information: Integrating MSBuild with CruiseControl.NET
这篇文章有一些很好的信息: Integrating MSBuild with CruiseControl.NET
Here's roughly how our solution works:
以下是我们的解决方案的大致工作原理:
- Developers build the 'debug' version of the app and run unit tests, then check in to SVN.
- CruiseControl sees the updates and calls our build script...
- Runs any new migrations on the build database
- Replaces the config files with the build server config
- Builds the 'debug' configuration of the app
- Runs all unit and integration tests
- Builds the 'deploy' configuration of the app
- Versions the DLLs with the current major/minor version and SVN revision, e.g. 1.2.0.423
- Moves this new build to a 'release' folder on our build server
- Removes unneeded files
- Updates IIS on the build server if required
- 开发人员构建应用程序的“调试”版本并运行单元测试,然后签入 SVN。
- CruiseControl 看到更新并调用我们的构建脚本......
- 在构建数据库上运行任何新的迁移
- 用构建服务器配置替换配置文件
- 构建应用程序的“调试”配置
- 运行所有单元和集成测试
- 构建应用程序的“部署”配置
- 使用当前主要/次要版本和 SVN 修订版对 DLL 进行版本控制,例如 1.2.0.423
- 将此新构建移动到我们构建服务器上的“发布”文件夹
- 删除不需要的文件
- 如果需要,更新构建服务器上的 IIS
Then when we have verified everything is ready to go up to live/staging we run another script to:
然后,当我们确认一切都准备好进行直播/登台时,我们运行另一个脚本:
- Run migrations on live/staging server
- MSDeploy: archive current live/staging site
- MSDeploy: sync site from build to live/staging
- 在实时/临时服务器上运行迁移
- MSDeploy:存档当前的实时/登台站点
- MSDeploy:将站点从构建同步到实时/暂存
It wasn't pretty getting to this stage, but it's mostly working like a charm now :D
到了这个阶段还不是很顺利,但现在大部分时间都像魅力一样工作:D
I'm going to try and keep this answer updated as we make changes to our process, as there seem to be several similar questions on SA now.
随着我们对流程进行更改,我将尝试更新此答案,因为现在似乎有几个关于 SA 的类似问题。
回答by jeremcc
I have used Visual Build Profor years, It's quite slick and easy to use and has many standard operations (like the ones you mentioned) built in.
我已经使用Visual Build Pro多年了,它非常灵活且易于使用,并且内置了许多标准操作(如您提到的那些)。
回答by Gary Richardson
I use Puppet, Makefiles to build RPMs and Bambooto do this for me. My system doesn't directly apply, and I'm not to familiar with the Windows world, but there are some transferable patterns.
我使用Puppet、 Makefiles 来构建 RPM 和Bamboo来为我做这件事。我的系统不直接适用,我对Windows世界也不熟悉,但有一些可移植的模式。
My make setup allows me to build RPM's for everything (php libs, php websites, perl modules, C apps, etc) that make up my app. This can be called manually, or through Bamboo. I transfer these RPM's into a yum repo and puppet handles making sure the latest (or correct) versions of software are installed in the cluster.
我的 make 设置允许我为构成我的应用程序的所有内容(php 库、php 网站、perl 模块、C 应用程序等)构建 RPM。这可以手动调用,也可以通过 Bamboo 调用。我将这些 RPM 传输到 yum 存储库和 puppet 句柄,以确保在集群中安装了最新(或正确)版本的软件。
Could you automate building software packages into MSI's? I think Puppet can manage installation of software packages and versions in Windows.
您可以自动将软件包构建到 MSI 中吗?我认为 Puppet 可以管理 Windows 中软件包和版本的安装。
回答by S P
I use msdeploy for this. It works perfect.
我为此使用 msdeploy。它完美无缺。
About Ant; for the .NET platform we have NAnt and you can use it in combination with MSDeploy; you have the possibility to call MSDeploy from your Nant-script.
关于蚂蚁;对于 .NET 平台,我们有 NAnt,您可以将其与 MSDeploy 结合使用;您可以从您的 Nant 脚本调用 MSDeploy。
Edited: Just to make things clear; you can do everything with msdeploy. Using Nant is not a requirement.
编辑:只是为了让事情清楚;你可以用 msdeploy 做任何事情。使用 Nant 不是必需的。
回答by Paul Shannon
Rather than using xcopy we managed to use the -source:dirpath command with UNC addresses to the servers with msdeploy. The key was the ignoreAcls=true and removing calls to username and password in the msdeploy string:
我们没有使用 xcopy,而是设法使用带有 UNC 地址的 -source:dirpath 命令到带有 msdeploy 的服务器。关键是 ignoreAcls=true 并删除对 msdeploy 字符串中的用户名和密码的调用:
msdeploy -verb:sync -source:dirpath=\build\e$\app -dest:dirpath=\live\d$\app,ignoreAcls=true
The example deploys the site from our build server's E drive to the D drive on our live server. There are some security considerations with exposing shares or this level of disk access on a live server. We're currently looking into using a limited access shared folder.
该示例将站点从我们构建服务器的 E 盘部署到我们实时服务器上的 D 盘。在实时服务器上公开共享或这种级别的磁盘访问有一些安全注意事项。我们目前正在考虑使用访问受限的共享文件夹。
We then pipe this output to a log file which is then moved to the backup archive for reference. The log file records which files were moved and when.Continuing the example above with the output pipe command:
然后,我们将此输出通过管道传输到日志文件,然后将其移动到备份存档以供参考。日志文件记录了哪些文件被移动以及何时被移动。 使用输出管道命令继续上面的例子:
... > E:\archive\msdeploy.log
回答by BozoJoe
No one mentioned Final Builder http://www.finalbuilder.com. Its on par with Visual build Pro. Good GUI for creating automated build deployment harnesses
没有人提到 Final Builder http://www.finalbuilder.com。它与 Visual build Pro 相当。用于创建自动构建部署工具的良好 GUI
回答by pdr
The only reason Nant should exist is so that you have a framework similar to Ant in which we can write Tasks using the .NET set of languages. If you don't want to get a pure .NET developer to write custom Tasks, I can't see any reason you can't use Ant. Just because you write your application in a .NET language, doesn't mean you have to use a .NET build tool.
Nant 存在的唯一原因是您拥有一个类似于 Ant 的框架,我们可以在其中使用 .NET 语言集编写任务。如果您不想让纯粹的 .NET 开发人员编写自定义任务,我看不出您有什么理由不能使用 Ant。仅仅因为您使用 .NET 语言编写应用程序,并不意味着您必须使用 .NET 构建工具。
回答by Jordi Bunster
回答by kemiller2002
Check out Setup Factory (from indigo rose). It's pretty robust in what it can do. It uses the Windows installer API. It can probably do what you need.
查看设置工厂(来自靛蓝玫瑰)。它的功能非常强大。它使用 Windows 安装程序 API。它可能可以满足您的需求。

