当前位置:Gxlcms > PHP教程 > PHP自动部署

PHP自动部署

时间:2021-07-01 10:21:17 帮助过:1人阅读

多人开发项目的时候不用自动部署,光维护就是一个非常大的负担,每次修改项目部署的时候总是小心翼翼,痛苦

为了减负,决定搞phing+xinc来实现自动部署

安装非常简单:(pear都没装的自己GOOGLE啦)

pear channel-discover pear.phing.info

pear install phing/phing

半年前就是alpha状态的svn包,到现在还没发布正式版,晕,估计没戏了.

执行 pear install pear/VersionControl_SVN

报错:(略)
pear install channel://pear.php.com/VersionControl_SVN-0.3.1

OK搞定

在装个FTP支持,需要net_ftp包

pear install Net_FTP
phing基本的都OK啦

现在需要写个build.xml部署文件,给个详细教程,其实跟ant的差不多

View Code

1
2
3 < project name ="lap" basedir ="." default ="help" >
4
5 < property name ="urlRepos" value ="svn://192.168.0.124/obj1" />
6 < property name ="todir" value ="./a" />
7
8 < echo msg ="obj start..." />
9
10 < target name ="help" >
11 < echo >
12 这样写的好处可以让人根据帮助来编译文件.
13
14
15 < target name ="build" >
16 ....
17
18
19 < target name ="prepare" depends ="build" >
20
21
22 < svncheckout username ="lonely" password ="ls880115" svnpath ="/usr/bin/svn" repositoryurl ="${urlRepos}" todir ="${todir}" />
23
24 < chmod mode ="0777" >
25 < fileset dir ="${todir}" />
26
27
28 < mkdir dir ="./b" />
29
30 < copy todir ="./b" >
31 < fileset dir ="${todir}" >
32 < include name ="b/**" />
33
34
35
36 < zip destfile ="./b/a.zip" >
37 < fileset dir ="${todir}" >
38 < include name ="b/**" />
39
40
41
42 < delete dir ="${todir}" />
43
44 < ftpdeploy host ="192.168.0.5" port ="21" username ="lonely" password ="ls880115" dir ="a" mode ="ascii" clearfirst ="true" >
45 < fileset dir ="./b" >
46 < include name ="**" />
47
48
49
50
51

想要什么自己编写部署文件

以上部分安装完毕每次提交都得手动运行命令,需要一个自动的,需要安装xinc

安装:

pear channel-discover pear.elektrischeslicht.de
pear channel-discover components.ez.no
pear install VersionControl_SVN-alpha
pear install Xinc/xinc-alpha

pear run-scripts xinc/Xinc

启动:

service xinc start

报错等级修改为:E_ALL & ~E_NOTICE

如果是5.3以后的PHP需要修改:

/usr/local/php/lib/php/PEAR/Config.php

line:1026 set_magic_quotes_runtime(0) =>ini_set("magic_quotes_runtime",0);

line:1033 set_magic_quotes_runtime($rt) =>ini_set("magic_quotes_runtime",$rt);

安装完毕

人气教程排行