I have a WordPress Website and recently I decided to
When I upgraded PHP from version 5.4 to version 7.2 on my CentOS 7 having apache as a web server and since I was using an external server (disk space of different machine like CDN but located at only one location) for media resources. I use to copy all the media from WP’s uploads folder to this remote server which is in the same network using SSH connection, So after upgrade whenever I use to upload an image it never got uploaded as PHP was unable to load SSH2 library, got below fatal error
PHP Fatal error: Uncaught Error: Call to undefined function ssh2_connect() in ...
To copy every image uploaded to upload’s folder to a remote server within same network use
Below is the error I use to get every-time I checked php version
$ php -v PHP Warning: PHP Startup: Unable to load dynamic library 'ssh2.so' (tried: /usr/lib64/php/modules/ssh2.so (/usr/lib64/php/modules/ssh2.so: undefined symbol: zval_used_for_init), /usr/lib64/php/modules/ssh2.so.so (/usr/lib64/php/modules/ssh2.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 PHP 7.2.15 (cli) (built: Feb 5 2019 19:50:47) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
Also Checked if PHP SSH2 extension/module was already installed from CentOS repo, It was not in my case so installed it using below command
$ sudo yum install php-ssh2
The installation was successful with some warnings
PHP Warning: Module 'ssh2' already loaded in Unknown on line 0
Checked if PHP list of module had SSH2
After some research finally found out that in /etc/
In the above image, you can see ssh2.ini are backed-up with different names whereas only 40-ssh2.ini module is kept as it is.
And IT WORKED!!!