PHP的安装SSH2在一个OSX 10.9.1 XAMPP的Apache服务器上运行 [英] Installing SSH2 for PHP to run on a Xampp Apache server on a OSX 10.9.1
问题描述
我在Mac上运行Xampp时与OS X 10.9.1,我试图开发一个网页,通过Ajax调用调用PHP脚本。 XAMPP是这里用于开发目的,并且不打算以形成在线页面的后端
I am running Xampp on a Mac with OS X 10.9.1 and I am trying to develop a web page that calls a PHP script through an Ajax call. Xampp is used here for development purposes and it is not intended to form the backend of an online page.
一个PHP脚本需要尽管SSH连接到远程机器,原因我结果
计划使用SSH2库。当我尝试运行命令:
A PHP script needs to connect though ssh to a remote machine, reason for which I
plan to use the ssh2 library. When I try to run the commands:
$连接= ssh2_connect('my.remote.machine.address',5432);
$connection = ssh2_connect('my.remote.machine.address', 5432);
我收到以下错误:
致命错误:调用未定义的函数ssh2_connect()在/Applications/XAMPP/xamppfiles/htdocs/Project/getdata.php第8行
Fatal error: Call to undefined function ssh2_connect() in /Applications/XAMPP/xamppfiles/htdocs/Project/getdata.php on line 8
和,通过调用'的phpinfo()',SSH2似乎并没有安装。我成功地设法在Windows上使用,Ubuntu和Linux的科学和ssh2_connect一个星期后,我似乎无法弄清楚,我不是在OSX我怀疑做正确的有可能是用碎路径或与Apache交互的问题服务器OSX带着。以下是我曾尝试:
and, by calling 'phpinfo()', ssh2 does not seem to be installed. I successfully managed to use ssh2_connect on Windows, Ubuntu and Scientific Linux and after a week I can't seem to figure out what I'm not doing right on a OSX I suspect there could be a problem with broken paths or interaction with the Apache server OSX came with. Here is what I have tried:
我。在MacPorts的和PECL方法(参考: http://lassebunk.dk/2011/05/26/installing-ssh2-for-php-on-mac-os-x/ ):
I. The MacPorts and PECL method (reference: http://lassebunk.dk/2011/05/26/installing-ssh2-for-php-on-mac-os-x/):
- 的东西已经在我的电脑上:X code(从网上商店),MacPorts的(安装在他们的网站),PHP 5.4.17显然自带的OSX,我不得不停止Apache服务器:
须藤apachectl中停止
sudo apachectl stop
让XAMPP的一个能用的。
so that the Xampp one worked.
- 运行命令:
sudo的港口安装libssh2
sudo port install libssh2
作为libssh2和OpenSSL库prerequisites使用ssh2_connect在PHP(参考:的 http://www.php.net/manual/en/ssh2.requirements.php ); OpenSSL的似乎已经安装对于Xampp的根据phpinfo()函数。
as the libssh2 and openssl libraries are prerequisites to using ssh2_connect in php (reference: http://www.php.net/manual/en/ssh2.requirements.php); openssl appears to be already installed on Xampp's according to phpinfo().
- 安装梨:
sudo的PHP /usr/lib/php/install-pear-nozlib.phar
sudo php /usr/lib/php/install-pear-nozlib.phar
- 安装家酿(否则'PECL安装命令失败):
红宝石-e$(卷曲-fsSL https://raw.github.com / mxcl /自制软件/去/安装)
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)"
- RAN:
酿造安装的autoconf
brew install autoconf
- 现在,我终于能够运行:
$ sudo的PECL安装ssh2-0.12
$ sudo pecl install ssh2-0.12
以/选择/本地为preFIX
with "/opt/local" as prefix
- 现在,我得到了一个不错的ssh2.so文件,我添加到相关的php.ini:
/应用/ XAMPP / xamppfiles的/ etc
/Applications/XAMPP/xamppfiles/etc
通过添加一行:
扩展= /选择/ local / lib目录/ php54 /扩展/无调试非ZTS-20100525 / ssh2.so
extension=/opt/local/lib/php54/extensions/no-debug-non-zts-20100525/ssh2.so
- 重新开始从出现且Xampp和SSH2仍然未找到GUI XAMPP的Apache Web服务器。
二。编译从终端方法(参考ssh2.so:zizifu的评论的http:// www.php.net/manual/en/ssh2.installation.php ):
II. The compile the ssh2.so from the terminal method (reference: zizifu's comment http://www.php.net/manual/en/ssh2.installation.php):
- 得到了来自libssh2存档 http://libssh2.org/ 和:
- got the libssh2 archive from http://libssh2.org/ and:
./配置
请
请安装
- got the latest ssh2 archive from http://pecl.php.net/package/ssh2
- 再有一个ssh2.so文件,将其添加到相关的php.ini,重新启动服务器,它仍然无法正常工作。
运行phpize
./配置--with-SSH2
./configure --with-ssh2
请
请安装
很抱歉,如果这有太多的细节,希望我给可以指出我在做什么错误的信息;我真的AP preciate任何解决方案/提示/东西来试图解决这个问题。
Sorry if this has too much detail, hopefully the information I gave can point what I'm doing wrong; I would really appreciate any solution/hint/thing to try to solve this issue.
推荐答案
你有没有考虑 phpseclib,一个纯粹的PHP执行SSH2 ?它具有超过libssh2 的若干优点,包括改进的便携性和速度。例如:
Have you considered phpseclib, a pure PHP SSH2 implementation? It has a number of advantages over libssh2, including improved portability and speed. Example:
<?php
include('Net/SSH2.php');
$ssh = new Net_SSH2('www.domain.tld');
if (!$ssh->login('username', 'password')) {
exit('Login Failed');
}
echo $ssh->exec('pwd');
echo $ssh->exec('ls -la');
?>
这篇关于PHP的安装SSH2在一个OSX 10.9.1 XAMPP的Apache服务器上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!