Home > Backend Development > PHP Tutorial > Use Php ssh2 extension to automatically submit svn to the test server, ssh2svn_PHP tutorial

Use Php ssh2 extension to automatically submit svn to the test server, ssh2svn_PHP tutorial

WBOY
Release: 2016-07-12 08:54:43
Original
1311 people have browsed it

Use Php ssh2 extension to automatically submit svn to the test server, ssh2svn

1. Install the ssh2 extension  

(1)window

<span>1</span><span>. 下载 php extension ssh2
下载地址 http:</span>//windows.php.net/downloads/pecl/releases/ssh2/<span>0.12</span>/<span>
根据自己PHP的版本去下载</span><span>2</span><span>. 解压完后,会有三个文件,libssh2.dll、php_ssh.dll、php_ssh2.pdb。
</span><span>3</span>. 将 php_ssh.dll、php_ssh2.pdb 放到你的 php 扩展目录下 php/ext/<span> 下。
</span><span>4</span>. 将libssh2.dll 复制到 c:/windows/system32 和 c:/windows/<span>syswow64 各一份
</span><span>5</span>. php.ini中加入 extension=<span>php_ssh2.dll
</span><span>6</span><span>. 重启服务器,即可使用php执行ssh连接操作了。
查看phpinfo(),是否有显示php_ssh2扩展加载成功。<br /></span>
Copy after login

(2)linux

<span>在linux下需要先安装扩展所需的依赖库
</span><span>1</span><span>.安装libssh2
wget http:</span>//www.libssh2.org/download/libssh2-<span>1.7</span>.<span>0</span><span>.tar.gz
tar zxf libssh2</span>-<span>1.7</span>.<span>0</span><span>.tar.gz
cd libssh2</span>-<span>1.7</span>.<span>0</span><span>
.</span>/configure --prefix=/usr/local/<span>libssh2
make </span>&&<span> make install
</span><span>2</span><span>.安装ssh2
wget http:</span>//pecl.php.net/get/ssh2-<span>0.12</span><span>.tgz
tar </span>-zxvf  ssh2-<span>0.12</span><span>.tgz
cd ssh2</span>-<span>0.12</span><span>
phpize
.</span>/configure --prefix=/usr/local/ssh2 --with-ssh2=/usr/local/<span>libssh2
make
#执行完以上过程后,在当前目录下的modules目录下会生成一个ssh2.so文件,这就是扩展PHP所需要的,将该文件拷贝到PHP库的存储目录下在修改PHP的配置文件即可。
cp modules</span>/ssh2.so /usr/local/php/lib/php/extensions/no-debug-non-zts-<span>20131226</span>/<span>
#注:PHP库的存储目录可能不同
vim </span>/usr/local/php/lib/<span>php.ini
添加extension</span>=<span>ssh2.so
#重启php
php </span>-m |grep ssh #可查看是否安装成功
Copy after login

2. The ssh2 extension is combined with svn to update and delete files and folders

(1) Create the following directory

file stores source code (co code is required for the first time, then use up later)

key stores the key

Log stores error information, file update and delete records

svn storage related operations (https://github.com/getCodeWarehouse/php_ssh2)

(2) Enable hooks in svn hooks, call php script

Say important things three times. You need to change the permissions~ You need to change the permissions~ You need to change the permissions~

svn up status is U D A, use array_pop to pop out useless data

Updates and new additions are of the same category. You need to determine whether it is a file or a folder and choose different functions. It is worth noting ssh2_sftp_mkdir. If this folder exists on the remote machine, an error will be reported

The reason why you use the rm command to delete a folder is because ssh2_sftp_rmdir cannot delete non-empty folders and cannot add parameters

(3) Test submission svn

Update file successfully

If the update speed is slow, blame the network _(┐『ε:)_

Related code: https://github.com/getCodeWarehouse/php_ssh2

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1119059.htmlTechArticleUse Php ssh2 extension to automatically submit svn to the test server, ssh2svn 1. Install the ssh2 extension (1) window 1. Download php extension ssh2 download address http: //windows.php.net/downloads/pecl/releas...
Related labels:
svn
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template