简体   繁体   English

部署网站的最佳做法

[英]Best practice for deploy website

I would like to know the best practice to deploy a website. 我想知道部署网站的最佳做法。

What I usually do is to minify all the javascript and css file, clean the html code from comments and publish my solution with Visual Studio. 我通常要做的是缩小所有javascript和css文件,清除注释中的html代码,然后使用Visual Studio发布我的解决方案。

There are other best way to put online a lower weigth website? 还有其他最好的方法可以在线访问一个较低的网站吗?

Try to execute Production deployments when there are few if any users online, such as at night or weekends. 如果在线用户很少(例如晚上或周末),请尝试执行生产部署。 Notify users that there will be a scheduled outage. 通知用户计划中的停机时间。

When deploying to the production environment, you can create a " App_Offline.htm " file and place it in the root of the ASP.NET website. 部署到生产环境时,可以创建一个“ App_Offline.htm ”文件并将其放置在ASP.NET网站的根目录中。 ASP.NET recognises this file has a special meaning - all dynamic page requests are shown this page instead of the page requested by the user. ASP.NET认识到此文件具有特殊含义-所有动态页面请求都显示在此页面上,而不是用户请求的页面上。 Typically this page displays a friendly message such as "The server is down for routine maintenance. Please try again in 30 minutes." 通常,此页面会显示一条友好消息,例如“服务器已关闭以进行常规维护。请在30分钟内重试。”

Another tip to make deployments less painful is to keep your web.config as similar as possible between your various environments such as Development, Test and Production. 减轻部署麻烦的另一个技巧是使您的web.config在开发,测试和生产等各种环境之间保持尽可能相似。 For the things that really have to change on the different environments, such as connection strings, you can extract these into their own connectionStrings.config file, by setting in web.config. 对于在不同环境下确实必须更改的事情,例如连接字符串,可以通过在web.config中进行设置将它们提取到它们自己的connectionStrings.config文件中。

For database deployments, there are some great third party tools (such as Teratrax Database Compare for SQL Server) which allow you to compare the schema and/or data between 2 databases and produce a SQL script that will migrate the target database to the schema of the other database. 对于数据库部署,有一些很棒的第三方工具(例如用于SQL Server的Teratrax数据库比较 ),使您可以比较2个数据库之间的架构和/或数据,并生成将目标数据库迁移到以下架构的SQL脚本:另一个数据库。 Whether this works for you will depend on your exact development practices. 这是否适合您将取决于您的确切开发实践。 If you cannot use such tools, you could script every database change, then replay those scripts when deploying to a different environment. 如果无法使用此类工具,则可以为每个数据库更改编写脚本,然后在部署到其他环境时重播这些脚本。

And of course you should ideally have a Test environment which is exactly like Production and enables do all your acceptance testing and to ensure your release is stable and your deployment is going to work before you do the real thing. 当然,理想情况下,您应该拥有一个与生产环境完全相同的测试环境,并能够进行所有验收测试,并确保发布稳定并确保部署在进行实际操作之前能够正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM