为网站创建颠覆存储库
创建网站存储库的最佳实践是什么?存储库是否已上线并且不需要从存储库中移动文件?或者您是否需要将文件从服务器存储库移动到 Web 服务器?
What is the best practice for creating a website repository? Is the repository the live on the and does not require moving files from the repo? Or do you need to move files from the server repository to the web server?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
永远、永远不会对实时服务器文件进行操作。
始终从本地副本签入和签出源代码管理,并准备部署包以上传到您的服务器。
Never, ever work against live server files.
Always check into and out of source control from a local copy and prepare a deployment package for upload to your server.
Randolpho 当然是正确的,您不想针对实时服务器文件进行工作。
您有一个源代码控制系统,其目的是让您可以跟踪谁在何时更改了什么,以便您可以在需要时将其更改回来,并知道该对谁大喊大叫,因为它搞砸了。
您拥有网络服务器来提供您的内容。
您有一个部署过程,即从安装在 Web 服务器上的源代码管理获取内容的过程。理想情况下,这不是手动过程。理想情况下,您希望在这里发生的是,当您想要部署到 Web 服务器时,您在命令行上键入几个单词,然后
1) 从源代码控制中提取内容
2) 验证内容是否全部存在,并且将执行您期望的操作
3) 内容移至 Web 服务器,并且重新启动所有需要重新启动的内容
4) 进行测试以确保 Web 服务器已启动并且其正在提供内容是您期望它提供的内容。
自动化是一件美妙的事情。
Randolpho is correct of course, you don't want to be working against the live server files.
You have a source control system, the purpose of this is so you can keep track of who changed what when and so you can change it back if you need to and know who to yell at for screwing it up.
You have the web server to serve your content.
And you have a deployment process which is the process of getting the content from source control installed on the web server. Ideally this is not a manual process. Ideally what you want to happen here is that when you want to deploy to the web server, you type a couple words on the command line and
1) The content is pulled from source control
2) It is verified that the content is all there and is going to do what you expect it to
3) The content is moved to the web server and anything that needs to be restarted is restarted
4) A test is done to make sure that the web server is up and that the content it is serving is the content you expect it to be serving.
Automation is a wonderful thing.
之后,您只需在 Webroot 中“提交”即可提交您的更改。
http://aymanh.com/subversion-a-quick-tutorial
http://www.abbeyworkshop.com/howto/misc/svn01/
After this you can simply 'commit' while in the webroot to commit your changes.
http://aymanh.com/subversion-a-quick-tutorial
http://www.abbeyworkshop.com/howto/misc/svn01/
您的 Web 服务器可以提供来自 Subversion 签出的页面,本质上是使用 svn 作为部署工具。
首先像平常一样设置一个 Subversion 存储库。只是通常的、公共的存储库布局,至少带有主干和标签。您可能已经有一个现有的存储库。进行开发并签入您的网站代码。为第一个版本创建标签。
然后在 Web 服务器上查看相应版本的副本。例如,cd /path/to/web/root/folder && svn co path_to_repository/tags/1.0 。
假设您更新站点并签入更改。当更新准备上线时,再次为其创建一个标签。在 Web 服务器上,通过执行以下操作切换到新版本:
cd /path/to/web/root/folder && svn sw path_to_repository/tags/1.1
请注意,这当然会在您的 Web 根目录中散布
.svn
目录。这可能是问题,也可能不是问题,具体取决于您要部署的内容。对于我的网站来说,这从来都不是问题(我确保它们通过 .htaccess 受到保护)。这个想法是,您在开发机器上进行开发,只有在新标签准备好并且准备好将 Web 服务器切换到新版本后才登录到 Web 服务器。
Your web server can serve pages that come from a Subversion checkout, essentially using svn as a deployment tool.
First set up a Subversion repository as usual. Just the usual, common repository layout with trunk and tags at least. You might already have an existing repository. Do your development and check in your website code. Create a tag for the first version.
Then on the web server, check out a copy of the appropriate version. For example,
cd /path/to/web/root/folder && svn co path_to_repository/tags/1.0 .
Let's say you update your site and check in the changes. When the update is ready to go live, once again create a tag for it. On the web server, switch to the new version by doing e.g.
cd /path/to/web/root/folder && svn sw path_to_repository/tags/1.1
Note that this will of course litter your web root with
.svn
directories. This may or may not be a problem, depending on what you're deploying. For my sites, it's never a problem (I ensure they're protected via .htaccess).The idea is that you do your development on development machines and only login to the web server after the new tag is ready and you're ready to switch the web server to the new version.