PHP7.3 - Can't get ssh2_connect working

0

This is my first time here and I could not find anything referencing this, so any help is appreciated. Keep im mind I am about 30 days in with EB so I am still a novice, but I do understand the basics and have loaded and ran a handful of sites already.

I noticed EB upgraded to 7.3 which is great news, but now I cannot get my application to recognize the ssh2_connect() function.

Currently I am adding this into my extensions:

files:
  "/etc/php.d/ssh2.ini" :
    mode: "000755"
    owner: root
    group: root
    content: |
      extension=ssh2.so

Which, this seems to add it correctly since the php.ini shows it in there. I have also rebooted the instance. Still, anytime I attempt to use our SSH2 functionality we get:

"Error: Call to undefined function ********ssh2_connect() in ********.php on line 157"

When checking PHP version here is my CLI notice:

[ec2-user@ip-*********** php.d]$ php -v
PHP Warning:  PHP Startup: Unable to load dynamic library 'ssh2.so' (tried: /usr/lib64/php/7.3/modules/ssh2.so (/usr/lib64/php/7.3/modules/ssh2.so: cannot open shared object file: No such file or directory), /usr/lib64/php/7.3/modules/ssh2.so.so (/usr/lib64/php/7.3/modules/ssh2.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP 7.3.11 (cli) (built: Oct 31 2019 18:30:52) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.11, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.11, Copyright (c) 1999-2018, by Zend Technologies

From this it seems like the ssh2.so file does not exist, but the phpinfo() says it does. So... should I attempt to manually install libssh2? Is there a way to install it on the fly with EB configs?

Any help or insight would be appreciated!

rpearl
asked 4 years ago2118 views
1 Answer
0

I found my own answer. It seems I was getting a false response from my php.ini regarding SSH2 being installed. Also, the SSH2 that it showed installed was also not compatible with PHP7.3. I terminated the EB instance and started a fresh one, then I was able to see that SSH2 was not installed at all. Below is the basic process to get SSH2 on PHP 7.3 in case anyone needs:

Check if installed:

php -r "print_r(get_loaded_extensions());"

Install libssh2-devel first:

sudo yum install libssh2-devel

Get PHP7.3 compatible version:

wget https://pecl.php.net/get/ssh2-1.2.tgz

Unpack and build:

tar -xzvf ssh2-1.2.tgz
cd ssh2-1.2
phpize
./configure
make
make install

Verify installed now:

php -r "print_r(get_loaded_extensions());"
rpearl
answered 4 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions