如何使用ant和git将php应用程序部署到实时web服务器


How to deploy php application to a live web server using ant and git

我需要一个可以使用ant和git将php应用程序部署到Web服务器的解决方案。我需要将文件复制到Web服务器,并运行一个php脚本来设置数据库。

我正在考虑使用sshexec来运行命令,这些命令将更新文件并运行php脚本

<target name="deploy">
    <sshexec host="host"
         port="22"
         username="user"
         password="****"
         trust="true"
         command="..."/>
</target>

有人有完整的解决方案吗?甚至是更好的解决方案?

如果您需要定期将一组不断变化的文件复制到服务器,并在每次更新后执行一个已知的脚本,则可以使用git push进行复制,并使用post-receive位挂钩(http://book.git-scm.com/5_git_hooks.html)以调用脚本。