安装/配置
在线手册:中文  英文

安装

安装此 PECL 扩展相关的信息可在手册中标题为 PECL 扩展的安装章节中找到。更多信息如新的发行版本、下载、源文件、 维护人员信息及变更日志等,都在此处: » http://pecl.php.net/package/ssh2.

PECL 扩展的 DLL 当前不可用。参见 在 Windows 上构建章节。


安装/配置
在线手册:中文  英文

用户评论:

Christer Michaelsen (2013-01-12 03:26:03)

RHEL 6 / CentOS 6 installation is easy:
#may be necessary to update version number
yum install http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
# set "priority=2" or whatever fits your needs
vi /etc/yum.repos.d/epel.repo
vi /etc/yum.repos.d/epel-testing.repo
yum install php-pecl-ssh2
service httpd reload
# possibly needed
setsebool -P httpd_can_network_connect 1

zizifu at gmail dot com (2012-08-28 07:58:16)

CentOS 6.2 64bit Installation Steps:
1. download the libssh2 package from http://libssh2.org, command as following:
tar vxzf libssh2-1.4.2.tar.gz
cd libssh2-1.4.2
./configure
make
make install
2. download the php-ssh2 package from http://pecl.php.net/package/ssh2:
tar vxzf ssh2-0.11.3
cd ssh2-0.11.3
phpize
./configure --with-ssh2
make
make install
and the ssh2.so file will copy into /usr/lib64/php/modules
check it.
3. modify the php.ini
vi /etc/php.ini
add the "extension=ssh2.so" to the extension part of php.ini
4. check the environment of php, use phpinfo();
5. enjoy

dreadwestern at gmail dot com (2012-07-26 14:47:10)

Steps for installing the extension package on Debian systems:
> sudo apt-get install libssh2-php
> sudo /etc/init.d/apache2 restart

imedina at grosshat dot com (2010-12-09 02:09:34)

Using PECL it must be specified the channel, since the beta version has to be choosen instead of stable one:
$ pecl install ssh2 channel://pecl.php.net/ssh2-version

adrya dot stembridge at gmail dot com (2008-11-21 08:01:18)

Installing ssh2:
1) Download and unpack tar.gz per instructions above.
2) Enter unpacked directory
3) vi patchfile, paste the following (except the ###) and save:
##########################################
--- ssh2.c.orig 2005-11-01 15:40:23.000000000 -0800
+++ ssh2.c 2007-10-05 11:29:50.000000000 -0700
@@ -477,7 +477,7 @@

ZEND_FETCH_RESOURCE(session, LIBSSH2_SESSION*, &zsession, -1, PHP_SSH2_SESSION_RES_NAME, le_ssh2_session);

-#if LIBSSH2_APINO < 200412301450
+#if LIBSSH2_VERSION_NUM < 0x001000
libssh2_session_methods(session, &kex, &hostkey, &crypt_cs, &crypt_sc, &mac_cs, &mac_sc, &comp_cs, &comp_sc, &lang_cs, &lang_sc);
#else
kex = libssh2_session_methods(session, LIBSSH2_METHOD_KEX);
##########################################
4) run patch < patchfile
5) vi /etc/php.ini, add extension = ssh2.so where appropriate and save.
6) restart apache, use phpinfo() to confirm

chris at 3menandarecorder dot com (2008-09-11 12:28:01)

To help someone avoid the headaches I did for a week. SSH2 functions have problems with the ssh2-beta & libssh2-0.18 even after patching with said patches on the internet.
ssh_exec will work fine
ssh2_shell will not work
In order to use ssh2_shell I had to roll back to libssh2-0.14 in order to get ssh2_shell function to work properly

arie dot mail at gmail dot com (2008-09-10 11:56:29)

Just a little note: when compiling this package after modifying the ssh2.c, do not use pecl build as it will not create an ssh2.so file (although it says it succeeded), use:
phpize
./configure --with-ssh2
make
you then need to copy the ssh2.so file into your extension dir if it didn't do so already.

volkirik at yahoo dot com dot tr (2008-05-08 07:33:50)

LIBSSH2_APINO was removed from the public header file. You need to patch ssh2.c to work with new libssh2 versions.
ssh2.c patch:
LINE 480:
search and change following line:
#if LIBSSH2_APINO < 200412301450
...
#else
to:
#if (defined(LIBSSH2_APINO) && LIBSSH2_APINO < 200412301450)
...
#else /* if LIBSSH2_APINO is not defined its v0.14 or higher. no problem! */
LINE 1216:
search and change following line:
#if (LIBSSH2_APINO > 200503221619)
to:
#if (defined(LIBSSH2_APINO) && (LIBSSH2_APINO > 200503221619)) || (defined(LIBSSH2_VERSION_NUM) && LIBSSH2_VERSION_NUM >= 0x001000)
Compile again!
----
Volkan K.

易百教程