每次提交后使用 SVN 的 FTP 将 PHP 部署到远程服务器
每次提交后,我无法找到使用 SVN 中的 FTP 将 Php 部署到远程服务器的解决方案。 如何通过FTP将仅添加或编辑的文件上传到服务器并从SVN中删除已删除的文件 我考虑编写提交后脚本......
I coudn't find the solution for Php deployment to remote server using FTP from SVN after each commit.
How can I upload to server by FTP the only added or edited files and delete the deleted files from SVN
I think about write post-commit script...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
好问题!
我不确定是否存在仅使用 PHP 来同步文件的方法。
我通常会使用第三方 FTP 同步工具,例如
rsync
或 ScriptFTP(商业)做同步部分。查看 phing,它有许多 FTP 扩展(称为“任务”)。但我没有与他们打交道的真实经验。
这篇博文提供了许多想法和方法:使用 phing 与共享主机
Good question!
I'm not sure a PHP-only approach to syncronizing files that way exists.
I would usually use third-party FTP sync tools like
rsync
or ScriptFTP (commercial) to do the syncronizing part.Take a look into phing, there are a number of FTP extensions (called "tasks") for it. I have no real world experience with them though.
This blog post offers a number of ideas and approaches: Using phing to sync files with shared hosting
您可以使用 svn2web 通过 Ftp 将每个提交的文件上传到服务器。 svn2web 是 php 脚本的集合,您可以将其用作 svn 挂钩。您可以将 ftp 服务器的地址、用户名和密码设置为目录上的 svn 属性。效果很好!
You could use svn2web to upload every commited file to a server via Ftp. Svn2web is a collection of php-scripts that you can use as svn hooks. You can set the address, username and password of the ftp-server as an svn property on a directory. Works great!
我使用 http://svn2ftp.com 这是一个 SVN 主机,允许在每次提交时远程部署到 S/FTP!
I use http://svn2ftp.com which is a SVN host that allows remote deployments to S/FTP on each commit!
如果您不想自己管理脚本,而只是想要一些有用的东西,您可以尝试使用托管服务。我使用 Deploy,它非常适合您描述的场景。如果您只有一个项目需要部署,它甚至是免费的。
If you don't want to manage the scripts by yourself, but just want something that works, you could try using a hosted service. I use Deploy, which works perfectly for the scenario you describe. And if you only have one project to deploy, it's even free.
对于我们的 php 项目,我们使用 Jenkins 一个持续集成工具。我们的存储库服务器是颠覆。每当我们进行代码更改时,我们都会使用 jenkins jobs 与 Beta staging & 合并。实时环境,然后部署应用程序。
您可以在 http://www.michaelpeacock.co.uk/blog/entry/jenkins-ci-an-introduction-for-php-developers
For our php project we use Jenkins a continuous integration tool. Our repository server is subversion. Whenever we do code changes, we use jenkins jobs to merge with the Beta staging & live environment and then deploy the application.
You can find more info on PHP application deployment using Jenkins on http://www.michaelpeacock.co.uk/blog/entry/jenkins-ci-an-introduction-for-php-developers
mybe cron + bash 脚本将被 svn 启动?
mybe cron + bash script which will be svn up ?
您是否研究过Beanstalk?它允许您一键将 Subversion 和 Git 项目部署到 FTP 服务器。但它不是免费的。另一个免费的替代方案是设置一个持续集成服务器,它将运行 rake 脚本来进行部署。
Have you looked into Beanstalk? It lets you deploy your Subversion and Git projects to your FTP server in one click. Its not free though. Another free alternative would be to setup a continuous integration server which would run a rake script to do your deployments.
你说什么,你从 SVN 签出到你的服务器(创建从 SVN 到生产服务器的工作副本),并且当你想要部署新版本时,你只需通过 SSH 连接到服务器并输入 < code>svn update ,这样,只有已编辑的最新文件才会被部署,不到一秒的时间,您就可以在生产环境中更新最新版本。
What do you say , you checkout from SVN to you'r server , ( create working copy from the SVN to the production server ) , and when ever you want to deploy a new version , you just connect to the server via SSH and type
svn update
, and there you go , only the latest files that have been edited are going to be deployed , and in a less then a second you have the latest version updated in production.最好的方法是(如果您的服务器基于 Linux)将 SVN 导出到新目录,然后移动新目录以替换旧目录(最好的方法是使用指向不同版本站点的符号链接)。这样,站点将在一两秒内不可用,而如果您进行 rsync 并且有一个大站点,如果您大幅更改单个文件,则该站点将被破坏,直到所有文件同步。
至于触发这个过程,最好的方法是使用 svn hooks。还可以考虑在发布之前进行一些自动化测试(对于基本功能),因为有时您可能会严重破坏您的主干,并且站点肯定会关闭:)
我们目前正在将上述方法合并到生产环境和设置中如下:
这一切都是通过使用标准控制台命令用 PHP 编写的。
The best way is (if your server is Linux based) to make an SVN Export to a new directory and then move the new directory to replace the old one (best way to do it is with symbolic links to different versions of the site). This way the site would be unavailable for a second or two, while if you rsync and have a big site, if you change drastically single file, the site would be broken until all files sync.
As for firing this procedure, the best way is to use svn hooks. Also consider doing some automated testing before release-ing (for basic functionality), because you can break your trunk pretty badly some time and the site would definitely be down :)
We are currently incorporating the approach described above in a production environment and the setup is as follows:
It's all written in PHP, by using standart console commands.