在使用Ubuntu 14.04(64位)源码编译安装PHP7并配置Apache2支持之后,无法直接通过命令安装libssh2-php
,因此需要手工编译安装。
1.安装编译libssh2-php
需要的依赖库
1 |
$ sudo apt-get install libssh2-1-dev libssh2-1 |
2.下载libssh2-php
的源代码
1 |
$ wget https://github.com/Sean-Der/pecl-networking-ssh2/archive/php7.zip |
3.解压缩文件
1 |
$ unzip php7.zip |
4.切换到目录
1 |
$ cd pecl-networking-ssh2-php7 |
5.使用phpize
配置插件编译环境
1 |
$ /opt/php-7.0.5/bin/phpize |
6.配置编译环境
1 |
$ ./configure --with-php-config=/opt/php-7.0.5/bin/php-config |
7.编译并安装
1 2 |
$ sudo make $ sudo make install |
执行之后,文件被安装到了/opt/php-7.0.5/lib/php/extensions/no-debug-zts-20151012
目录下面。
8.配置php.ini
加载插件
1 |
$ sudo vim /opt/php-7.0.5/etc/php.ini |
找到如下内容
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
;;;;;;;;;;;;;;;;;;;;;; ; Dynamic Extensions ; ;;;;;;;;;;;;;;;;;;;;;; ; If you wish to have an extension loaded automatically, use the following ; syntax: ; ; extension=modulename.extension ; ; For example, on Windows: ; ; extension=msql.dll ; ; ... or under UNIX: ; ; extension=msql.so ; ; ... or with a path: ; ; extension=/path/to/extension/msql.so ; ; If you only provide the name of the extension, PHP will look for it in its ; default extension directory. ; ; Windows Extensions ; Note that ODBC support is built in, so no dll is needed for it. ; Note that many DLL files are located in the extensions/ (PHP 4) ext/ (PHP 5+) ; extension folders as well as the separate PECL DLL download (PHP 5+). ; Be sure to appropriately set the extension_dir directive. ; ;extension=php_bz2.dll ;extension=php_curl.dll ;extension=php_fileinfo.dll ;extension=php_gd2.dll ;extension=php_gettext.dll ;extension=php_gmp.dll ;extension=php_intl.dll ;extension=php_imap.dll ;extension=php_interbase.dll ;extension=php_ldap.dll ;extension=php_mbstring.dll ;extension=php_exif.dll ; Must be after mbstring as it depends on it ;extension=php_mysqli.dll ;extension=php_oci8_12c.dll ; Use with Oracle Database 12c Instant Client ;extension=php_openssl.dll ;extension=php_pdo_firebird.dll ;extension=php_pdo_mysql.dll ;extension=php_pdo_oci.dll ;extension=php_pdo_odbc.dll ;extension=php_pdo_pgsql.dll ;extension=php_pdo_sqlite.dll ;extension=php_pgsql.dll ;extension=php_shmop.dll ; The MIBS data available in the PHP distribution must be installed. ; See http://www.php.net/manual/en/snmp.installation.php ;extension=php_snmp.dll ;extension=php_soap.dll ;extension=php_sockets.dll ;extension=php_sqlite3.dll ;extension=php_tidy.dll ;extension=php_xmlrpc.dll ;extension=php_xsl.dll |
在最下面增加
1 |
extension=ssh2.so |
9.重启Apache2
加载动态模块
1 |
$ sudo service apache2 restart |