尝试在 php 上安装 ssh2 [英] Trying to install ssh2 on php

查看:55
本文介绍了尝试在 php 上安装 ssh2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先我运行的是 PHP 5.3.3,CentOS 5.7 (2.6.18-274.3.1.el5xen)

Firstly I'm running PHP 5.3.3, CentOS 5.7 (2.6.18-274.3.1.el5xen)

其次,我基本上不知道我在做什么......对不起!

Secondly, I basically have no idea what I'm doing... sorry!

首先,我从 http://www.libssh2.org/ 安装了 libssh2.Ran configure, make, make install.不太了解所有这些内容,但按照在线说明操作似乎有效.

First of all I installed libssh2 from http://www.libssh2.org/. Ran configure, make, make install. Don't really understand all of this stuff, but following online instructions seemed to work.

然后跑

pecl install ssh2

到目前为止一切顺利.

按照说明在php.ini中添加了相关的扩展行.重启apache:

Added the relevant extension line to php.ini, as instructed. Restarted apache:

service httpd restart

一切都好.

但是在 phpInfo() 中找不到任何对 ssh 的引用.

But then can't find any reference to ssh in phpInfo().

尝试过

php -m | grep ssh2

并得到以下错误:

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/ssh2.so' - /usr/lib64/php/modules/ssh2.so: undefined symbol: libssh2_sftp_readdir_ex in Unknown on line 0

我做错了什么/遗漏了什么,我该如何解决?

What have I done wrong/missed out, and how can I fix it?

推荐答案

我在 CentOs 6.3 上遇到了类似的问题,我按照这个指南有点不同.

I had a similar problem with CentOs 6.3, and I followed this guide a bit differently.

1) 安装需要的包:

yum install automake make php-devel libtool openssl-devel gcc++ gcc

2) 更改目录(/usr/lib/php 如果您有 32 位操作系统):

2) Change directory (/usr/lib/php if you have a 32bit OS):

cd /usr/lib64/php

3) 下载源代码(最新的截至 2013/02/28,查看最新的这里):

3) Download the source (latest as of 2013/02/28, check latest here):

wget http://pecl.php.net/get/ssh2-0.12.tgz

4) 创建一个构建目录(我不喜欢我的系统乱七八糟)并解压包:

4) Create a build directory (I don't like mess in my system) and untar the package:

mkdir build-dir
mv ssh2-0.12.tgz build-dir
cd build-dir
tar xzvf ssh2-0.12.tgz

5) 准备编译步骤并编译:

5) Prepare the compile step and compile:

phpize
./configure –with-ssh2
make

6) 复制系统中的模块(/usr/lib/php/modules/ssh2.so 如果你有 32 位操作系统):

6) Copy the module in the system (/usr/lib/php/modules/ssh2.so if you have a 32bit OS):

cp modules/ssh2.so /usr/lib64/php/modules/ssh2.so

7) 更改配置并将这一行添加到 /etc/php.d/ssh2.ini (虽然我不需要在我的设置中这样做,也许是因为我已经这样做了过去):

7) Change configuration and add this line to /etc/php.d/ssh2.ini (although I didn't need to do this on my setup, maybe because I had already done this in the past):

extension=ssh2.so

8) 如果你想删除构建目录:

8) If you want you can delete the build directory:

cd ../../
rm -f build-dir

这篇关于尝试在 php 上安装 ssh2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆