PHP Install SSH2 on Windows machine

被刻印的时光 ゝ 提交于 2019-12-17 03:18:12

问题


I am trying to install this on a Windows+Apache machine. Documentation says that SSH2 requires the OpenSSL and libssh2 libraries. I have added this lines in my php.ini file:

extension=php_openssl.dll
extension=php_ssh2.dll

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

Can anyone explain me how to install this service?

Thanks

ps: i'm italian, sorry for my english...


回答1:


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.dll and php_ssh2.pdb files in the ext folder (e.g. C:\php\ext);
    • copied libssh2.dll file to C:\Windows\system32 and (if you got Win64) C:\Windows\SysWOW64 folder(s);
  3. Run the following command to register the DLL:

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

Final note

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

Hope this helps.




回答2:


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

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

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

3) Copy php_ssh2.dll and php_ssh2.pdb to php/ext folder.

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

5) Restart Apache.




回答3:


  1. Place php_ssh2.dll in ext folder
  2. Place libssh2.dll in php folder
  3. Restart IIS

that work for me

  • PHP 5.4.25 NTS + Windows Server 2012



回答4:


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

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

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

Hope this helps, regards.




回答5:


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

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)




回答6:


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.

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




回答7:


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.

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

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

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

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

4.) restart the apache server

Worked Like a charm

CHEERS




回答8:


First of all, your question reveals two misconceptions:

  1. The Requirements section 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.dll requires that you actually have a file called php_ssh2.dll in your PHP's ext directory and you probably don't have it, mainly because it isn't bundled with PHP.

If we check the Installation chapter 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:

  • You need a php_ssh2.dll file 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.

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



来源:https://stackoverflow.com/questions/15134421/php-install-ssh2-on-windows-machine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!