Install libssh2 in a non-standard location on SXCE

Libssh2 is a php extension that allows ssh connections to a remote machine in order to execute shell commands or even access the remote shell. Subsequently, the output from these commands can be displayed in a browser, as required. Evidently, it can be convenient to use it in various scenarios, where such a need may arise.

It's official website defines Libssh2 as:

libssh2 is a library implementing the SSH2 protocol as defined by Internet Drafts: SECSH-TRANS, SECSH-USERAUTH, SECSH-CONNECTION, SECSH-ARCH, SECSH-FILEXFER, SECSH-DHGEX, SECSH-NUMBERS, and SECSH-PUBLICKEY.

Many a times, we are faced with situations where we do not have root privileges on a unix box, and hence we are unable to install tools in their default path (eg. /usr/local/bin, /usr/local/include). As a result, we have to customize the installation by providing a non-standard location (eg. ~/$HOME), and providing additional flags for procedures like configure, build and install.

In this article, we have listed the steps involved in installing the libssh2 library on Solaris Express Community Edition. However, the same set of steps will work on any other unix distro, with minor changes.

Install libssh2
cd /tmp
wget http://voxel.dl.sourceforge.net/sourceforge/libssh2/libssh2-0.18.tar.gz
tar xvf libssh2-0.18.tar.gz
cd libssh2-0.18

Since, the /usr/local directory is "read-only", we'll provide a prefix in the configure step

-bash-3.2# ./configure --prefix=/opt/install

 -bash-3.2# make all install

Install PECL ssh2

-bash-3.2# wget http://pecl.php.net/get/ssh2-0.10.tgz
-bash-3.2# tar xvf ssh2-0.10.tar
x package.xml, 3091 bytes, 7 tape blocks
x ssh2-0.10/config.m4, 2149 bytes, 5 tape blocks
x ssh2-0.10/ssh2.c, 43225 bytes, 85 tape blocks
x ssh2-0.10/php_ssh2.h, 5397 bytes, 11 tape blocks
x ssh2-0.10/ssh2_fopen_wrappers.c, 36414 bytes, 72 tape blocks
x ssh2-0.10/ssh2_sftp.c, 22321 bytes, 44 tape blocks

Patch the ssh2.c file
-bash-3.2# cd ssh2-0.10
-bash-3.2# vi ssh2.c

Seach for
#if LIBSSH2_APINO < 200412301450
Change it to as followings
#if LIBSSH2_VERSION_NUM < 0x001000
Save the file and run

From the ssh2-0.10 directory, run

-bash-3.2# /usr/php/5.2/bin/phpize
Configuring for:
PHP Api Version:         20041225
Zend Module Api No:      20060613
Zend Extension Api No:   220060519


-bash-3.2# env CPPFLAGS="-I/opt/install/include" LDFLAGS="-L/opt/install/lib" ./configure --with-ssh2=/opt/install/lib --with-php-config=/usr/php/5.2/bin/php-config --prefix=/opt/install

-bash-3.2# make

-bash-3.2# make install
Installing shared extensions:     /var/php/5.2/modules/

Add the entry for the ssh2 extension in php.ini
vi /etc/php/5.2/php.ini
under Dynamic Extension, add
extension=ssh2.sos

Restart the apache service
svcadm restart apache22

Check if the service started successfully
svcs apache22

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

Prateek Parekh

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today