每次提交后使用 SVN 的 FTP 将 PHP 部署到远程服务器

发布于 2024-08-28 10:08:52 字数 109 浏览 12 评论 0原文

每次提交后,我无法找到使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

情绪失控 2024-09-04 10:08:52

好问题!

我不确定是否存在仅使用 PHP 来同步文件的方法。

我通常会使用第三方 FTP 同步工具,例如 rsyncScriptFTP(商业)做同步部分。

查看 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

一袭白衣梦中忆 2024-09-04 10:08:52

您可以使用 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!

不美如何 2024-09-04 10:08:52

我使用 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!

虫児飞 2024-09-04 10:08:52

如果您不想自己管理脚本,而只是想要一些有用的东西,您可以尝试使用托管服务。我使用 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.

冰火雁神 2024-09-04 10:08:52

对于我们的 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

旧街凉风 2024-09-04 10:08:52

mybe cron + bash 脚本将被 svn 启动?

mybe cron + bash script which will be svn up ?

小情绪 2024-09-04 10:08:52

您是否研究过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.

笛声青案梦长安 2024-09-04 10:08:52

你说什么,你从 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.

夏末染殇 2024-09-04 10:08:52

最好的方法是(如果您的服务器基于 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:

  • A commit goes in the trunk
    • Before it's actually commited, tests are ran on the code to see if everything works
  • After several commits a deploy comes (usually developer supervised)
    • Tests are run again
    • If they are successful - all ok
    • If they fail, old export is returned and the site is fully operational once again

It's all written in PHP, by using standart console commands.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文