From: Sharat Ojha on
Hi all,



We are trying to use SFTP connection to remote host in our project. So for
that we are using SSH2 functions of PHP. But the script where we have used
those functions was throwing the following error:



*PHP Fatal error: Call to undefined function ssh2_connect() *

* *

By doing some work around we came to know that to remove this error we
mainly need 3 packages: OpenSSL, libssh2 and ssh2 modules.

Out of them OpenSSL module was present on the server. So we have installed
other two packages through procedure given on the link below :

http://hostechs.com/2008/07/installing-ssh2-for-php-shell-connections-how-to/
i.e.,



We have installed *“libssh2”* package using following set of commands :



[root(a)box1 ~]wget
http://voxel.dl.sourceforge.net/sourceforge/libssh2/libssh2-0.18.tar.gz
[root(a)box1 ~]tar -zxvf libssh2-0.18.tar.gz
[root(a)box1 ~]cd libssh2-0.18
[root(a)box1 libssh2-0.18]# ./configure
[root(a)box1 libssh2-0.18]# make
[root(a)box1 libssh2-0.18]# make install



Then we have installed ssh2 module using following set of commands:

[root(a)box1 ~]# wget http://pecl.php.net/get/ssh2-0.10.tgz
[root(a)box1 ~]# tar -xzf ssh2-0.10.tgz
[root(a)box1 ~]# cd ssh2-0.10
[root(a)box1 ssh2-0.10]# phpize && ./configure --with-ssh2 && make



Then we have copied ssh2.so from
*“/home/amitdesh/ssh2-0.10/modules”*location to
*"/home/y/lib/php/20060613" *folder as this folder is mentioned as
*extension_dir
= "/home/y/lib/php/20060613" in php.ini file.*

Also we have added the following line in php.ini file to add the new ssh
extension:

*extension=ssh2.so*



But still by running our script we are getting the following error :



*PHP Warning: PHP Startup: ssh2: Unable to initialize module*

*Module compiled with module API=20050922, debug=0, thread-safety=0*

*PHP compiled with module API=20060613, debug=0, thread-safety=0*

*These options need to match*

* in Unknown on line 0*



Please let me know if anybody worked on SFTP in PHP and faced similar issue..




Thanks & Regards,

Sharat Ojha
From: "Tommy Pham" on
> -----Original Message-----
> From: Sharat Ojha [mailto:ojhasharat(a)gmail.com]
> Sent: Monday, July 26, 2010 9:43 PM
> To: php-general(a)lists.php.net
> Subject: [PHP] Requires help: Unable to install ssh2 module in PHP.
>
> Hi all,
>
>
>
> We are trying to use SFTP connection to remote host in our project. So for
> that we are using SSH2 functions of PHP. But the script where we have used
> those functions was throwing the following error:
>
>
>
> *PHP Fatal error: Call to undefined function ssh2_connect() *
>
> * *
>
> By doing some work around we came to know that to remove this error we
> mainly need 3 packages: OpenSSL, libssh2 and ssh2 modules.
>
> Out of them OpenSSL module was present on the server. So we have
> installed other two packages through procedure given on the link below :
>
> http://hostechs.com/2008/07/installing-ssh2-for-php-shell-connections-
> how-to/
> i.e.,

Sharat,

Wrong reference source to begin with?? Try this:
http://www.php.net/manual/en/ssh2.requirements.php

>
> We have installed *“libssh2”* package using following set of commands :
>
>
>
> [root(a)box1 ~]wget
> http://voxel.dl.sourceforge.net/sourceforge/libssh2/libssh2-0.18.tar.gz
> [root(a)box1 ~]tar -zxvf libssh2-0.18.tar.gz
> [root(a)box1 ~]cd libssh2-0.18
> [root(a)box1 libssh2-0.18]# ./configure
> [root(a)box1 libssh2-0.18]# make
> [root(a)box1 libssh2-0.18]# make install
>

http://sourceforge.net/projects/libssh2/
Current version of libssh2 on sourceforge is 1.1 (released 2009.04.02) .... seems like you're using a very outdated version...

>
>
> Then we have installed ssh2 module using following set of commands:
>
> [root(a)box1 ~]# wget http://pecl.php.net/get/ssh2-0.10.tgz
> [root(a)box1 ~]# tar -xzf ssh2-0.10.tgz
> [root(a)box1 ~]# cd ssh2-0.10
> [root(a)box1 ssh2-0.10]# phpize && ./configure --with-ssh2 && make
>
>
>
> Then we have copied ssh2.so from
> *“/home/amitdesh/ssh2-0.10/modules”*location to
> *"/home/y/lib/php/20060613" *folder as this folder is mentioned as
> *extension_dir = "/home/y/lib/php/20060613" in php.ini file.*
>
> Also we have added the following line in php.ini file to add the new ssh
> extension:
>
> *extension=ssh2.so*
>
>
>
> But still by running our script we are getting the following error :
>
>
>
> *PHP Warning: PHP Startup: ssh2: Unable to initialize module*
>
> *Module compiled with module API=20050922, debug=0, thread-safety=0*
>
> *PHP compiled with module API=20060613, debug=0, thread-safety=0*
>
> *These options need to match*
>
> * in Unknown on line 0*
>

And thus, the mismatch version problem... I figure you're probably doing this on Linux. If you're compiling on *BSD, the ports build will fetch the appropriate dependencies for you when you build the main port from the tree ;)

Regards,
Tommy

>
>
> Please let me know if anybody worked on SFTP in PHP and faced similar issue.
>
>
>
>
> Thanks & Regards,
>
> Sharat Ojha

From: "Tommy Pham" on
> -----Original Message-----
> From: Tommy Pham [mailto:tommyhp2(a)gmail.com]
> Sent: Monday, July 26, 2010 11:08 PM
> To: 'php-general(a)lists.php.net'
> Subject: RE: [PHP] Requires help: Unable to install ssh2 module in PHP.
>
> > -----Original Message-----
> > From: Sharat Ojha [mailto:ojhasharat(a)gmail.com]
> > Sent: Monday, July 26, 2010 9:43 PM
> > To: php-general(a)lists.php.net
> > Subject: [PHP] Requires help: Unable to install ssh2 module in PHP.
> >
> > Hi all,
> >
> >
> >
> > We are trying to use SFTP connection to remote host in our project. So
> > for that we are using SSH2 functions of PHP. But the script where we
> > have used those functions was throwing the following error:
> >
> >
> >
> > *PHP Fatal error: Call to undefined function ssh2_connect() *
> >
> > * *
> >
> > By doing some work around we came to know that to remove this error we
> > mainly need 3 packages: OpenSSL, libssh2 and ssh2 modules.
> >
> > Out of them OpenSSL module was present on the server. So we have
> > installed other two packages through procedure given on the link below :
> >
> > http://hostechs.com/2008/07/installing-ssh2-for-php-shell-connections-
> > how-to/
> > i.e.,
>
> Sharat,
>
> Wrong reference source to begin with?? Try this:
> http://www.php.net/manual/en/ssh2.requirements.php
>
> >
> > We have installed *“libssh2”* package using following set of commands :
> >
> >
> >
> > [root(a)box1 ~]wget
> > http://voxel.dl.sourceforge.net/sourceforge/libssh2/libssh2-0.18.tar.g
> > z
> > [root(a)box1 ~]tar -zxvf libssh2-0.18.tar.gz
> > [root(a)box1 ~]cd libssh2-0.18
> > [root(a)box1 libssh2-0.18]# ./configure
> > [root(a)box1 libssh2-0.18]# make
> > [root(a)box1 libssh2-0.18]# make install
> >
>
> http://sourceforge.net/projects/libssh2/
> Current version of libssh2 on sourceforge is 1.1 (released 2009.04.02) ....
> seems like you're using a very outdated version...
>
> >
> >
> > Then we have installed ssh2 module using following set of commands:
> >
> > [root(a)box1 ~]# wget http://pecl.php.net/get/ssh2-0.10.tgz
> > [root(a)box1 ~]# tar -xzf ssh2-0.10.tgz
> > [root(a)box1 ~]# cd ssh2-0.10
> > [root(a)box1 ssh2-0.10]# phpize && ./configure --with-ssh2 && make
> >
> >

Forgot 1 more thing (it's getting late and I've been up for about 20 hrs :P now), if you're running PHP 5.3, you should be using 0.11.0 from pecl.
http://pecl.php.net/package-changelog.php?package=ssh2&release=0.11.0

Regards,
Tommy

> >
> > Then we have copied ssh2.so from
> > *“/home/amitdesh/ssh2-0.10/modules”*location to
> > *"/home/y/lib/php/20060613" *folder as this folder is mentioned as
> > *extension_dir = "/home/y/lib/php/20060613" in php.ini file.*
> >
> > Also we have added the following line in php.ini file to add the new
> > ssh
> > extension:
> >
> > *extension=ssh2.so*
> >
> >
> >
> > But still by running our script we are getting the following error :
> >
> >
> >
> > *PHP Warning: PHP Startup: ssh2: Unable to initialize module*
> >
> > *Module compiled with module API=20050922, debug=0, thread-safety=0*
> >
> > *PHP compiled with module API=20060613, debug=0, thread-safety=0*
> >
> > *These options need to match*
> >
> > * in Unknown on line 0*
> >
>
> And thus, the mismatch version problem... I figure you're probably doing this
> on Linux. If you're compiling on *BSD, the ports build will fetch the
> appropriate dependencies for you when you build the main port from the
> tree ;)
>
> Regards,
> Tommy
>
> >
> >
> > Please let me know if anybody worked on SFTP in PHP and faced similar
> issue.
> >
> >
> >
> >
> > Thanks & Regards,
> >
> > Sharat Ojha