libssh2 and ssh2

General discussion forum for the Zend Server
Post Reply
lionelviot
Posts: 11
Joined: Tue Jul 27, 2010 11:21 am

libssh2 and ssh2

Post by lionelviot » Tue Jul 27, 2010 4:13 pm

Hello,
I wish to add those libraries (libssh2 & ssh2) to zend studio and server on a Mac os X. I need to create a ssh connection to my database server (via port forwarding created in ssh_conf).
I have downloaded the .tar files and followed this tutorial : http://naeh.net/installer-libssh2-ssh2-pour-php/
I'm not an expert in adding a library on an unix system and this tutorial didn't help me.
I'm stuck at the very beginning... Any kind of help will be welcome.

Thanks

shahar
Posts: 244
Joined: Mon Oct 06, 2008 12:37 pm
Location: Israel
Contact:

Re: libssh2 and ssh2

Post by shahar » Wed Jul 28, 2010 9:03 am

Hi,

First you will need XCode installed - make sure you have it and if not get it from the Apple web site.

To install libssh (and most other open source libraries) on Mac I would recommend using MacPorts. This is out of scope for this forum but I think it's an easier way, as MacPort takes care of installing all the necessary tools and dependencies for each library you want to build.

Another way is to do it yourself - make sure you build the library and all it's dependencies.

Then, you can build the ssh2 extension using the 'pecl' tool bundled with Zend Server - assuming you have the necessary tools and libraries installed this would simply be a matter of running

Code: Select all

sudo /usr/local/zend/bin/pecl install ssh2
and enabling the extension from the Zend Server GUI.

If you get stuck at any point, please provide more information - e.g. what stage did you get stuck in and what error message you got.

Shahar.
Shahar Evron <shahar.e@zend.com>
Product Manager, Zend Technologies

lionelviot
Posts: 11
Joined: Tue Jul 27, 2010 11:21 am

Re: libssh2 and ssh2

Post by lionelviot » Wed Jul 28, 2010 2:38 pm

Hello,
thanks for your answer, i'm very happy to find an helpfull hand.
I have followed your explanation but i had already done some things.
Xcode is installed.
I think that i've managed to install the libssh2 library. I had permission troubles but finally it worked without any errors:

Code: Select all

./configure && make all install
About ssh2 i have compilation problems. I have few warnings like :

Code: Select all

ssh2.c:1105: warning: passing argument 4 of ‘add_assoc_stringl_ex’ discards qualifiers from pointer target type
I have seen that 2 patchs exist for mac os x but it doesn't change anything.
When i import the ssh2.so in zend/lib/php_extension and change the php.ini file adding "extension=ssh2.php" i have the error :

Code: Select all

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/zend/lib/php_extensions/ssh2.so' - dlopen(/usr/local/zend/lib/php_extensions/ssh2.so, 9): no suitable image found.  Did find: /usr/local/zend/lib/php_extensions/ssh2.so: mach-o, but wrong architecture in Unknown on line 0
With or without the patch it's the same error...
Nevermind, i want it to work so i have tried with pecl. First i've updated it (otherwise it doesn't work) :

Code: Select all

sudo /usr/local/zend/bin/pear channel-update pear.php.net
sudo /usr/local/zend/bin/pear upgrade-all
An then i tested your code :

Code: Select all

sudo /usr/local/zend/bin/pecl install ssh2
dyld: Library not loaded: /usr/local/zend/mysql/lib/mysql/libmysqlclient.16.dylib
  Referenced from: /usr/local/zend/bin/php
  Reason: image not found
Trace/BPT trap
The error is pretty clear. It's "/usr/local/zend/mysql/lib/libmysqlclient.16.dylib" with only one "mysql".
I'm abble to change the php-conf file but when i change php file (which is hard to read (compiled or crypted i dunno)) i have a segmentation fault.
One more time i'm out of idea. I don't know how to modify this file, i have check all .ini or conf file, except here and in php-conf, there is nothing.
I hope you could help me once again.

lionelviot
Posts: 11
Joined: Tue Jul 27, 2010 11:21 am

Re: libssh2 and ssh2

Post by lionelviot » Wed Jul 28, 2010 2:53 pm

i've tried a little trick : create the folder that the installation is waiting for "/mysql/lib/mysql" and do a copy/paste of the correct folder.
It worked but i have the same error than before i updated pear

Code: Select all

sudo /usr/local/zend/bin/pecl install ssh2
pecl.php.net is using a unsupported protocol - This should never happen.
install failed

shahar
Posts: 244
Joined: Mon Oct 06, 2008 12:37 pm
Location: Israel
Contact:

Re: libssh2 and ssh2

Post by shahar » Sun Aug 01, 2010 9:57 am

Hi,

Firsts, try to run the following whenver opening a new shell / terminal window, to make sure your envrionment is properly set up to work with Zend Server's PHP / pecl / pear etc. :

Code: Select all

source /etc/zce.rc
Hopefully this will solve the libmysqlclient issues.

As for pecl issues, run the following, which should fix the protocol errors:

Code: Select all

sudo /usr/local/zend/bin/pecl channel-update -f pecl.php.net
(note the -f flag - it's important!)

Now, for your libssh2 issues: you can probably ignore the warnings. As for being unable to load the extension, I'm guessing you are using a 64 bit Mac - Zend Server is 32 bit and when you compile libraries or extensions to use with Zend Server, they must also be compiled for 32 bit. There are several threads in this forum on that matter - there is also a good blog post from Ralph Schindler here: http://ralphschindler.com/2010/05/12/co ... ow-leopard

Hope this helps,

Shahar.
Shahar Evron <shahar.e@zend.com>
Product Manager, Zend Technologies

lionelviot
Posts: 11
Joined: Tue Jul 27, 2010 11:21 am

Re: libssh2 and ssh2

Post by lionelviot » Mon Aug 02, 2010 4:30 pm

Hi, thanks for your answer,
I'have worked one other whole day on this problem and the result isn't glorious unfortunatly.
I have used your command "source /etc/zce.rc" and modify my path adding "/usr/local/zend/bin"
I have fixed the pecl problem by updating the channel.
Nevertheless, pecl's installation doesn't work

Code: Select all

make: *** [ssh2.lo] Error 1
ERROR: `make' failed
The problem is that i have to patch ssh2.c before trying to install it on a mac os x 10.6 with

Code: Select all

51d50
< static
487c486
< #if defined(LIBSSH2_APINO) && LIBSSH2_APINO < 200412301450
---
> #if LIBSSH2_VERSION_NUM < 0x001000
Back to the beginning, you are right about zend server. It's a i386 only compilation.
So I have reinstalled in a temporary file (like in your link) a libssh2 using arguments

Code: Select all

CC="gcc -arch i386" CXX="g++ -arch i386" CFLAGS="-O -arch i386" CPPFLAGS="-O -arch i386" LDFLAGS="-arch i386"
All goes fine.
I have pathed my ssh2.c file and tried to install it using this command

Code: Select all

sudo ./configure --disable-shared --with-libssh2=/Users/xxx/Desktop/libssh2 CC="gcc -arch i386" CXX="g++ -arch i386" CFLAGS="-O -arch i386" CPPFLAGS="-O -arch i386" LDFLAGS="-arch i386"
Configuration goes fine but make failed.

Code: Select all

checking for libssh2_banner_set in -lssh2... no
configure: error: libssh2 version >= 0.4 not found
Without the arguments for 32 bits compilation it works but the ssh2.iso file is based on a 64 bits architecture so that i can't include it in Zend. After a quick check on internet, most of people are talking about a problem in config.m4 that i don't have.
I'm currently using zend server 4.0, is the 5.0 version 64 bits compatible? I've seen that linux's version are, so i keep a hope...
If you have any other ideas you are welcome.

urkman
Posts: 34
Joined: Thu Jan 15, 2009 9:15 am

Re: libssh2 and ssh2

Post by urkman » Thu Aug 19, 2010 1:28 pm

Hello,

I have the same Problem here on my SnowLeopard Mac.
When I build it using 64-bit everything went fine, but the extension could not be loaded.
When I try to build it using 32 bit, I get the same error asking for libssh >= 0.4...

Perhaps somebody can help us :-)

Greetings
Urkman

Post Reply