PHP 在 Windows 机器上安装 SSH2

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15134421/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 08:38:15  来源:igfitidea点击:

PHP Install SSH2 on Windows machine

phpwindowsapachedlllibssh2

提问by LaYle

I am trying to install thison a Windows+Apachemachine. Documentation says that SSH2 requires the OpenSSLand libssh2libraries. I have added this lines in my php.inifile:

我正在尝试在机器上安装Windows+Apache。文档说 SSH2 需要OpenSSLlibssh2库。我在我的php.ini文件中添加了以下几行:

extension=php_openssl.dll
extension=php_ssh2.dll

and restarted Apache but it still not working (Fatal error: Call to undefined function ssh2_connect()).

并重新启动了 Apache,但它仍然无法正常工作 ( Fatal error: Call to undefined function ssh2_connect())。

Can anyone explain me how to install this service?

谁能解释我如何安装此服务?

回答by Alex B

Here's how I did it:

这是我如何做到的:

  1. Downloaded Win32 SSH2 PECL extension from this location(choose the appropriate version);

  2. Extracted the archive's content and:

    • placed php_ssh2.dlland php_ssh2.pdbfiles in the extfolder (e.g. C:\php\ext);
    • copied libssh2.dllfile to C:\Windows\system32and (if you got Win64) C:\Windows\SysWOW64folder(s);
  3. Run the following command to register the DLL:

    C:\> regsvr32 libssh2.dll
    
  4. Restarted Apache.

  1. 这个位置下载了 Win32 SSH2 PECL 扩展 (选择合适的版本);

  2. 提取档案的内容并:

    • 放置php_ssh2.dllphp_ssh2.pdb文件ext夹中的文件(例如C:\php\ext);
    • libssh2.dll文件复制到C:\Windows\system32和(如果你有 Win64)C:\Windows\SysWOW64文件夹;
  3. 运行以下命令注册DLL:

    C:\> regsvr32 libssh2.dll
    
  4. 重新启动阿帕奇。

Final note

最后说明

If you got PHP x64, you have to lookup for the x64 version of the SSH2 library / DLLs. This siteoffers some Win64 compiled libraries for PHP, try here first.

如果您有 PHP x64,则必须查找 SSH2 库/DLL 的 x64 版本。 该站点提供了一些用于 PHP 的 Win64 编译库,请先在这里尝试。

Hope this helps.

希望这可以帮助。

回答by user2893097

If anyone is having trouble installing SSH2, here's how I did it:

如果有人在安装 SSH2 时遇到问题,我是这样做的:

1) Download SSH2 PECL library from PHP.net[choose the appropriate version].

1) 从PHP.net[选择合适的版本]下载 SSH2 PECL 库。

2) Copy libssh2.dllto System32[x86] or SysWOW64[x64] folder.

2) 复制libssh2.dllSystem32[x86] 或SysWOW64[x64] 文件夹。

3) Copy php_ssh2.dlland php_ssh2.pdbto php/extfolder.

3) 复制php_ssh2.dll并复制php_ssh2.pdbphp/ext文件夹。

4) Remove ';' from the ;extension=php_ssh2.dllline in php.ini. If this line is not on your php.ini, add it.

4) 删除';' 从;extension=php_ssh2.dllphp.ini 中的行开始。如果此行不在您的 php.ini 中,请添加它。

5) Restart Apache.

5)重新启动Apache

回答by MrTeChId

  1. Place php_ssh2.dllin ext folder
  2. Place libssh2.dllin php folder
  3. Restart IIS
  1. 放置php_ssh2.dll在ext文件夹
  2. 发生libssh2.dll在PHP文件夹
  3. 重新开始 IIS

that work for me

这对我有用

  • PHP 5.4.25 NTS + Windows Server 2012
  • PHP 5.4.25 NTS + Windows Server 2012

回答by Cristian B.

If you are running xamp 3.2.1 and PHP 5.6.8, this could be helpful for you.

如果您运行的是 xamp 3.2.1 和 PHP 5.6.8,这可能对您有所帮助。

Do what alex b said, and download the package that corresponds dependindg your php version (and bits) from this page (link)

执行 alex b 所说的操作,然后从此页面(链接)下载与您的 php 版本(和位)相对应的软件包

I've downloaded and replaced in C:\xampp\php\ext and it worked!

我已经在 C:\xampp\php\ext 中下载并替换了它,它起作用了!

Hope this helps, regards.

希望这有帮助,问候。

回答by lodev09

libssh2 (deps): http://windows.php.net/downloads/php-sdk/deps/

libssh2(deps):http: //windows.php.net/downloads/php-sdk/deps/

php_ssh2 (ext): http://windows.php.net/downloads/pecl/releases/ssh2/0.12/

php_ssh2 (ext): http://windows.php.net/downloads/pecl/releases/ssh2/0.12/

Versions prior to 5.5 has already the libssh2.dll (from the second link)

5.5 之前的版本已经有 libssh2.dll(来自第二个链接)

回答by Maks Z.

I have wamp with PHP 5.6.25/7.0.10 – MySQL 5.7.14 installed and I cm currently working on PHP 7.0. I had the same error. I checked using phpinfo() if both librarires OpenSSL and libssh2 was working(you can google how to check it). After I could see they was working, I have downloaded php_ssh2.dll at http://pecl.php.net/package/ssh2/1.0/windows(can also be found http://windows.php.net/downloads/pecl/releases/ssh2/) for the 7.0 version, put it to php\ext folder. Than I included it in php.ini file using extension=php_ssh2.dll.

我已经安装了 PHP 5.6.25/7.0.10 – MySQL 5.7.14,我目前正在使用 PHP 7.0。我有同样的错误。我使用 phpinfo() 检查了 librarires OpenSSL 和 libssh2 是否都在工作(你可以谷歌如何检查它)。在我看到它们正在工作后,我在http://pecl.php.net/package/ssh2/1.0/windows下载了 php_ssh2.dll (也可以在http://windows.php.net/downloads/pecl /releases/ssh2/) 对于 7.0 版本,将其放入 php\ext 文件夹。比我使用 extension=php_ssh2.dll 将它包含在 php.ini 文件中。

Then it appeared at phpinfo(). And it worked. Hope it helps.

然后它出现在 phpinfo() 处。它奏效了。希望能帮助到你。

回答by akashBhardwaj

Fix that worked for me. Am running xampp v. 3.2.1 apache 2.2 facing the same issue tried placing the dll files at different c: location but failed finally this helped.

修复对我有用的。我正在运行 xampp v. 3.2.1 apache 2.2 面临同样的问题,尝试将 dll 文件放在不同的 c: 位置,但最终失败了这有帮助。

1.) Download the version specific dll files from http://pecl.php.net/package/ssh2/0.12/windowsand extract the files

1.) 从http://pecl.php.net/package/ssh2/0.12/windows下载特定版本的 dll 文件并解压文件

Note that even though you are in 64 bit version of windows download the 32 version of THREAD SAFE ssh i.e. Thread Safe (TS) x86 as per your version of php

请注意,即使您使用的是 64 位版本的 Windows,请根据您的 php 版本下载 32 版本的 THREAD SAFE ssh 即线程安全 (TS) x86

2.) Add/replace the libssh2.dll at C:\xampp\php (standard installation)

2.) 添加/替换 C:\xampp\php 中的 libssh2.dll(标准安装)

3.) Add/replace the php_ssh2.dll & php_ssh2.pdb within the C:\xampp\php\ext (standard installation)

3.) 添加/替换 C:\xampp\php\ext 中的 php_ssh2.dll & php_ssh2.pdb(标准安装)

4.) restart the apache server

4.) 重启apache服务器

Worked Like a charm

像魅力一样工作

CHEERS

干杯

回答by álvaro González

First of all, your question reveals two misconceptions:

首先,你的问题揭示了两个误解:

  1. The Requirementssection actually says this:

    The ? OpenSSL and ? libssh2 libraries are required. Ensure that the development libraries are installed, where a typical package name might be openssl-dev.

    It isn't talking about PHP extensions, it's talking about third-party libraries that have nothing to do with PHP.

  2. extension=php_ssh2.dllrequires that you actually have a file called php_ssh2.dllin your PHP's extdirectory and you probably don't have it, mainly because it isn't bundled with PHP.

  1. 要求一节居然这样说:

    这 ?OpenSSL 和 ? 需要 libssh2 库。确保安装了开发库,其中典型的包名称可能是 openssl-dev。

    它不是在谈论 PHP 扩展,而是在谈论与 PHP 无关的第三方库。

  2. extension=php_ssh2.dll要求您实际上php_ssh2.dll在 PHPext目录中调用了一个文件,而您可能没有它,主要是因为它没有与 PHP 捆绑在一起。

If we check the Installationchapter we can read that SSH2 is a PECL extension. There're a few links with instructions but I can make a summary of the important info:

如果我们查看安装章节,我们可以了解到 SSH2 是一个 PECL 扩展。有几个带有说明的链接,但我可以总结一下重要信息:

  • You need a php_ssh2.dllfile that matches your PHP installation.
  • Neither the PHP team nor the PECL team distribute such file.
  • Installing PECL extensions on Windows is hard. You need to download the C source code, grab a C compiler and make the file yourself, or find someone who already did it for you.
  • 您需要一个php_ssh2.dll与您的 PHP 安装相匹配的文件。
  • PHP 团队和 PECL 团队都没有分发此类文件。
  • 在 Windows 上安装 PECL 扩展很困难。您需要下载 C 源代码,获取 C 编译器并自己制作文件,或者找到已经为您制作过的人。

Said that, unless you Google for php_ssh2.dlland find something relevant, you're probably out of luck.

说,除非你用谷歌搜索php_ssh2.dll并找到相关的东西,否则你可能不走运。