1. Installing the SSH2 Extension
(1) window
1 download PHP extension ssh2 download address http://windows.php.net/downloads/pecl/releases/ssh2/0.12/ Download according to your PHP version 2. After the decompression, there will be three files, Libssh2.dll, Php_ssh.dll, php_ssh2.pdb. 3. Put Php_ssh.dll, php_ssh2.pdb into your PHP extension directory under php/ext/ . 4. Copy the Libssh2.dll to C:/windows/system32 and c:/windows/syswow64 one copy of the 5. php.ini add extension=php_ssh2.dll6. Restart the server to use PHP to perform the SSH connection operation. View Phpinfo (), whether there is a display PHP_SSH2 extension loaded successfully.
(2) Linux
The dependent libraries required to install the extension are required under Linux1. Install Libssh2wget http:www.libssh2.org/download/libssh2-1.7.0. Tar.gztar zxf libssh2-1.7.0. TAR.GZCD Libssh2-1.7.0./configure--prefix=/usr/local/Libssh2make&&Make Install2. Install Ssh2wget http:pecl.php.net/get/ssh2-0.12. Tgztar-ZXVF ssh2-0.12. TGZCD SSH2-0.12phpize./configure--prefix=/usr/local/ssh2--with-ssh2=/usr/local/libssh2make# After performing the above process, in the current directory under the modules directory will generate a ssh2.so file, which is required to extend PHP, copy the file to the PHP Library storage directory in the modified PHP configuration file. CP Modules/ssh2.so/usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/#注: The storage directory for the PHP library may be different vim/usr/local/php/lib/php.ini Adding extension=ssh2.so# Restart phpphp-M |grep ssh #可查看是否安装成功
2.SSH2 extension combined with SVN to update and delete file folders
(1) Create the following directory
File storage Source (the first time you need the CO code, and then use up)
Key holds keys
Log holds error message, file update Delete record
SVN store related operations (HTTPS://GITHUB.COM/GETCODEWAREHOUSE/PHP_SSH2)
(2) Open the hook in SVN hooks and invoke the PHP script
Important thing to say three times to change permissions ~ To change permissions ~ To change permissions ~
SVN up state has U D A, use Array_pop to eject useless data
Update and add the same as a class, need to determine whether it is a file or folder, choose a different function, it is worth noting that Ssh2_sftp_mkdir, if the remote machine exists This folder will be an error
The RM command is used to delete a folder because Ssh2_sftp_rmdir cannot delete non-empty folders and cannot add parameters
(3) Test submission SVN
Update file succeeded
If the update is slow, then blame the network bar _ (┐"ε:) _
related code: HTTPS://GITHUB.COM/GETCODEWAREHOUSE/PHP_SSH2
The above describes the PHP ssh2 extension application, including the ssh,php aspects of the content, I hope that the PHP tutorial interested in a friend helpful.