如何将网站部署到网络服务器

如何将网站部署到网络服务器

本文介绍了如何将网站部署到网络服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的公司,我们有一组8个Web开发人员用于我们的商业网站(完全用PHP编写,但这并不重要)。群组中的每个人都在同一时间处理不同的项目,每当他们完成任务时,都会立即部署它(因为业务正在快速发展)。



目前,开发发生在一个共享服务器上,所有开发人员都使用相同的代码库(使用RCS将文件远离其他文件)。当部署到期时,更改的文件将被复制到暂存服务器,然后同步脚本将文件上传到我们的主要网络服务器,从其分发到其他9台服务器。



很高兴地,Web开发团队要求我们寻求帮助,以改善流程(在我们抱怨一段时间之后),现在我们设置开发环境的想法如下:




  • 具有虚拟目录的dev服务器,以便每个人都有自己的代码库,

  • SVN(或任何其他VCS)跟踪更改

  • 一个用于测试持有最新签入代码的中央服务器



现在的问题是:如何将更改的文件部署到服务器上,而不会意外从其他项目中上传错误?我的第一个想法是简单地从存储库导出最新版本,但是这不会完全控制文件。



你如何管理这种情况?你有什么样的部署脚本?



(作为一个特殊的挑战:网站在过去十年中已经有机发展,所以这些项目并不分散在小块中,但是一个特定功能的文件是散布在目录树上。)

解决方案

Cassy - 你显然有很长的路要走,你会得到你的来源代码管理完全按顺序排列,但这听起来像你在路上!



拥有个别沙箱肯定有助于事情。接下来,请确保网站始终只是一个干净的检查,特定修订,标签或分支从subversion。



我们使用git,但我们有一个类似的设置。我们使用版本号标记特定版本(在git中,我们还可以添加标签的描述;对发行说明有好处),然后我们有一个脚本,任何有权访问执行发布的脚本都可以运行,需要两个参数 - 哪个系统将被更新(数据中心,如果我们正在更新测试或生产服务器),然后是版本号(标签)。



脚本使用sudo然后在共享帐户中运行发行脚本。它检查相关版本,最大限度地减少JavaScript和CSS ,将代码推送到相关服务器环境,然后重新启动需要重新启动的内容。发布脚本的最后一行连接到其中一个Web服务器,并将错误日志尾随。



在 我们在每页的底部包含一个html评论使用当前的服务器名称和版本 - 可以轻松查看现在正在运行的。



和一堆其他家务管理这样的事情...


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).

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.

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:

  • A dev server with virtual directories, so that everybody has their own codebase,
  • SVN (or any other VCS) to keep track of changes
  • a central server for testing holding the latest checked in code

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?

(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 - 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!

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.

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).

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.

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 and a bunch of other housekeeping tasks like that...

这篇关于如何将网站部署到网络服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 06:31