0

I am trying to install php_ssh2 extension on wamp. I do the following things:

  1. copy libssh2.dll to C:\Windows\SysWOW64
  2. register the dll file: Regsvr32 libssh2.dll
  3. copy php_ssh2.dll to C:\wamp\bin\php\php5.5.12\ext
  4. add extension line in php.ini

i got the message:

enter image description here

Hope if someone will know to help !
Thanks in advance

2
  • Are you using the 32bit or 64 bit WampServer? Commented Nov 3, 2014 at 20:49
  • I am using 64bit WampServer Commented Nov 4, 2014 at 7:41

2 Answers 2

1

libssh2 is a PITA. I'd just use phpseclib's libssh2-compatibility-layer:

https://github.com/phpseclib/libssh2-compatibility-layer

Example:

<?php
include('phpseclib.php');

$ssh = ssh2_connect('www.domain.tld');
echo ssh2_fingerprint($ssh);

Basically, it just uses phpseclib to emulate all of the ssh2_* functions.

Sign up to request clarification or add additional context in comments.

Comments

1

The libssh2.dll does not need all that doing to it.

As a simple rule of thumb when using WAMPServer, nothing needs to be placed into the C:\windows\.... folders. If you do you destroy the ability to switch versions of Apache/PHP/MySQL at the click of a link which is afterall one of the primary reason to use WAMPServer over other similiar products.

How To Install the SSH2 PHP Extension to WAMPServer.

DOWNLOAD the SSH2 extension from here

  • click on the word 'DLL' next to the windows icon to get to the windows builds.

For WAMPServer you will need the TS ( Thread Safe ) versions Download the Thread Safe version that matches your WAMPServer i.e. 32bit/64bit and the major version of PHP you want to install it into i.e. PHP5.4 or PHP5.5 etc.

If you are running 32bit WAMPServer even on a 64bit Windows you should be using the 32bit (x86) version of ssh2!

Using wampmanager, stop all services

wampmanager -> Stop all Services

Extract these 2 files from the zip (rememeber the SSH2 files are specific to a version of PHP, so make sure you use the correct zip file).

copy libssh2.dll to \wamp\bin\php\phpx.y.z\
copy php_ssh2.dll to \wamp\bin\php\phpx.y.z\ext

Edit php.ini ( using the wampmanager menus )

wampmanager -> PHP -> php.ini

Locate the section containing the extension parameters and add this line

extension=php_ssh2.dll

IF you are using WAMPServer 2.5.15 or later you can skip this next step as it has already been incorporated into the WAMPServer refresh process.

IF you are using WAMPServer 2.5 or older versions :

Edit \wamp\scripts\config.inc.php Find this section of the file,

$phpDllToCopy = array (

And add this line into the array, it can go anywhere in that list

$phpDllToCopy = array (
    'libssh2.dll',

Start all the services again

wampmanager -> Start all Services 

Look at

wampmanager -> PHP -> PHP Extensions

You should see php_ssh2 in the list with a tick beside it.

Now you need to get WAMPManager to rebuild the SYMLINKS into the \apachex.y.z\bin folder. So using the wampamanager menus DO:

wampmanager -> Apache -> Version -> 2.4.9    

( click on the version number, it may or may not be 2.4.9 )

This should take a few second and then you are ready to test that ssh2 is loaded.

Now launch localhost

wampmanager -> localhost

On the homepage you should see ssh2 in the list of Loaded Services

enter image description here

Click the phpinfo() link on the WAMPServer homepage and you should see the following information proving that SSH2 has been loaded

enter image description here

Now if you want to use SSH2 from PHP used at the command line ( PHP CLI ) then you need to do one more thing.

Edit \wamp\bin\php\php{version}\php.ini

Locate the section containing the extension parameters and add this line

extension=php_ssh2.dll

You are done.

5 Comments

Thanks for your answer, i am looking in php_info() -> "Registered PHP Streams" and i don't see following ssh2.shell, ssh2.exec, ssh2.tunnel, ssh2.scp, ssh2.sftp, i see just php, file, glob, data, http, ftp, zip, compress.zlib, compress.bzip2, https, ftps, phar
Have you undone all the stuff you did earlier? Have you got the correct version of SSH2 that matches your PHP version? Have you removed libssh2.dll from C:\Windows\SysWOW64 and unregistered is as a service?
Yes, the main issue is "Call to undefined function ssh2_exec" and it caused by wrong installation in my opinion.
I amended my answer after looking a little closer as the problem. I just tested this so it should now be a complete solution. I HOPE?
Thanks for the link for ssh2. All the other answers everywhere had old links and I just couldn't find one for php 7.2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.