1. Installing the SSH2 extension
(1) window
1. Download the PHP extension ssh2 download address http://windows.php.net/downloads/pecl/releases/ssh2/0.12/According to your PHP version to download 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 in your PHP extension directory under php/ext/. 4. Copy the Libssh2.dll to C:/windows/system32 and c:/windows/syswow64 one copy of 5. Add Extension=php_ssh2.dll6 to the php.ini. You can use PHP to perform an SSH connection operation by restarting the server. View Phpinfo (), whether there is a display PHP_SSH2 extension loaded successfully.
(2) Linux
Under Linux, you need to install the dependent libraries required for the extension 1. 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 Add 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