Install SSH with PHP

apps

#1

I need install SSH package in my custom PHP, but I don’t know how do it.

I installed my own custom PHP using the script of wiki.dreamhost.com. After I try install the libssh2 (http://br2.php.net/manual/en/ref.ssh2.php) but appear the follow error:

make[1]: Entering directory /home/.mowse/mydomain/temp/libssh2-0.14/src' gcc -o channel.o channel.c -c -g -O2 /usr/include -I/usr/include -Wall -I../include/ -fPIC gcc: cannot specify -o with -c or -S and multiple compilations make[1]: *** [channel.o] Error 1 make[1]: Leaving directory/home/.mowse/mydomain/temp/libssh2-0.14/src’
make: *** [all] Error 1

Then I try install ssh2 “phpize && ./configure --with-ssh2 && make” but appear the follow error:

Configuring for:
PHP Api Version: 20020918
Zend Module Api No: 20020429
Zend Extension Api No: 20050606
Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF
environment variable is set correctly and then rerun this script.

Anybody can help me?
I REALLY NEED install this feature.


#2

Try installing autoconf, then. I know I needed it for when I compiled PHP with eAccelerator; it was a pain to set up, but I got it working with some help.

emufarmers.com
Very little to do with either emus or farmers!


#3

I tried to reinstall the PHP with the follow script:

#!/bin/bash

Abort on any errors

set -e

The domain in which to install the PHP CGI script.

export DOMAIN=“mydomain.com

Where do you want all this stuff built? I’d recommend picking a local

filesystem.

Don’t pick a directory that already exists! We clean up after

ourselves at the end!

SRCDIR=${HOME}/source

And where should it be installed?

INSTALLDIR=${HOME}/php5

Set DISTDIR to somewhere persistent, if you plan to muck around with this

script and run it several times!

DISTDIR=${HOME}/dist

Pre-download clean up!!!

rm -fr $SRCDIR $DISTDIR

Update version information here.

AUTOCONF="autoconf-2.60"
AUTOMAKE="automake-1.9.6"
CCLIENT="imap-2004g"
CCLIENT_DIR=“imap-2004g” # Another pest!
CURL="curl-7.15.5"
LIBEVENT="libevent-1.1b"
LIBICONV="libiconv-1.11"
LIBIDN="libidn-0.6.8"
LIBMCRYPT="libmcrypt-2.5.7"
LIBTOOL="libtool-1.5.22"
LIBXML2="libxml2-2.6.26"
LIBXSLT="libxslt-1.1.17"
M4="m4-1.4.7"
MHASH="mhash-0.9.7.1"
PHP5="php-5.2.0"
ZLIB="zlib-1.2.3"
FREETYPE=“freetype-2.2.1”

What PHP features do you want enabled?

PHPFEATURES="–prefix=${INSTALLDIR}
–with-config-file-path=${INSTALLDIR}/etc/php5/${DOMAIN}
–enable-force-cgi-redirect
–with-xml
–with-libxml-dir=${INSTALLDIR}
–with-freetype-dir=${INSTALLDIR}
–enable-soap
–with-openssl=/usr
–with-mhash=${INSTALLDIR}
–with-mcrypt=${INSTALLDIR}
–with-zlib-dir=${INSTALLDIR}
–with-jpeg-dir=/usr
–with-png-dir=/usr
–with-gd
–enable-gd-native-ttf
–enable-ftp
–with-exif
–enable-sockets
–enable-wddx
–with-iconv=${INSTALLDIR}
–enable-sqlite-utf8
–enable-calendar
–with-curl=${INSTALLDIR}
–enable-mbstring
–enable-mbregex
–with-mysql=/usr
–with-mysqli
–without-pear
–with-gettext
–with-imap=${INSTALLDIR}
–with-imap-ssl=/usr"

---- end of user-editable bits. Hopefully! ----

Push the install dir’s bin directory into the path

export PATH=${INSTALLDIR}/bin:$PATH

#setup directories
mkdir -p ${SRCDIR}
mkdir -p ${INSTALLDIR}
mkdir -p ${DISTDIR}
cd ${DISTDIR}

Get all the required packages

wget -c http://us3.php.net/distributions/${PHP5}.tar.gz
wget -c http://mirrors.usc.edu/pub/gnu/libiconv/${LIBICONV}.tar.gz
wget -c http://easynews.dl.sourceforge.net/sourceforge/mcrypt/libmcrypt-2.5.7.tar.gz
wget -c http://ftp.acc.umu.se/pub/GNOME/sources/libxml2/2.6/${LIBXML2}.tar.gz
wget -c http://ftp.acc.umu.se/pub/GNOME/sources/libxslt/1.1/${LIBXSLT}.tar.gz
wget -c http://superb-west.dl.sourceforge.net/sourceforge/mhash/${MHASH}.tar.gz
wget -c http://www.zlib.net/${ZLIB}.tar.gz
wget -c http://curl.haxx.se/download/${CURL}.tar.gz
wget -c http://kent.dl.sourceforge.net/sourceforge/freetype/${FREETYPE}.tar.gz
wget -c ftp://alpha.gnu.org/pub/gnu/libidn/${LIBIDN}.tar.gz
wget -c ftp://ftp.cac.washington.edu/imap/old/${CCLIENT}.tar.Z

wget -c http://ftp.gnu.org/gnu/m4/${M4}.tar.gz
wget -c http://ftp.gnu.org/gnu/libtool/${LIBTOOL}.tar.gz
wget -c http://ftp.gnu.org/gnu/autoconf/${AUTOCONF}.tar.gz
wget -c http://ftp.gnu.org/gnu/automake/${AUTOMAKE}.tar.gz
wget -c http://www.monkey.org/~provos/${LIBEVENT}.tar.gz

echo ---------- Unpacking downloaded archives. This process may take several minutes! ----------

cd ${SRCDIR}

Unpack them all

tar xzf ${DISTDIR}/${PHP5}.tar.gz
tar xzf ${DISTDIR}/${LIBICONV}.tar.gz
tar xzf ${DISTDIR}/${LIBMCRYPT}.tar.gz
tar xzf ${DISTDIR}/${LIBXML2}.tar.gz
tar xzf ${DISTDIR}/${LIBXSLT}.tar.gz
tar xzf ${DISTDIR}/${MHASH}.tar.gz
tar xzf ${DISTDIR}/${ZLIB}.tar.gz
tar xzf ${DISTDIR}/${CURL}.tar.gz
tar xzf ${DISTDIR}/${LIBIDN}.tar.gz
tar xzf ${DISTDIR}/${M4}.tar.gz
tar xzf ${DISTDIR}/${LIBTOOL}.tar.gz
tar xzf ${DISTDIR}/${AUTOCONF}.tar.gz
tar xzf ${DISTDIR}/${AUTOMAKE}.tar.gz
tar xzf ${DISTDIR}/${LIBEVENT}.tar.gz
tar xzf ${DISTDIR}/${FREETYPE}.tar.gz
uncompress -cd ${DISTDIR}/${CCLIENT}.tar.Z |tar x

Build them in the required order to satisfy dependencies.

begin custom installation

#m4 - MUST BE FIRST
cd ${SRCDIR}/${M4}
./configure --prefix=${INSTALLDIR}
make
make install

#libtool - MUST BE SECOND
cd ${SRCDIR}/${LIBTOOL}
./configure --prefix=${INSTALLDIR}
make
make install

#autoconf - MUST BE THIRD
cd ${SRCDIR}/${AUTOCONF}
./configure --prefix=${INSTALLDIR}
make
make install

#automake - MUST BE FOURTH
cd ${SRCDIR}/${AUTOMAKE}
./configure --prefix=${INSTALLDIR}
make
make install

#libiconv
cd ${SRCDIR}/${LIBICONV}
./configure --enable-extra-encodings --prefix=${INSTALLDIR}

make clean

make
make install

#libxml2
cd ${SRCDIR}/${LIBXML2}
./configure --with-iconv=${INSTALLDIR} --prefix=${INSTALLDIR}

make clean

make
make install

#libxslt
cd ${SRCDIR}/${LIBXSLT}
./configure --prefix=${INSTALLDIR}
–with-libxml-prefix=${INSTALLDIR}
–with-libxml-include-prefix=${INSTALLDIR}/include/
–with-libxml-libs-prefix=${INSTALLDIR}/lib/

make clean

make
make install

#zlib
cd ${SRCDIR}/${ZLIB}
./configure --shared --prefix=${INSTALLDIR}

make clean

make
make install

#libmcrypt
cd ${SRCDIR}/${LIBMCRYPT}
./configure --disable-posix-threads --prefix=${INSTALLDIR}

make clean

make
make install

#libmcrypt lltdl issue!!
cd ${SRCDIR}/${LIBMCRYPT}/libltdl
./configure --prefix=${INSTALLDIR} --enable-ltdl-install
make
make install

#mhash
cd ${SRCDIR}/${MHASH}
./configure --prefix=${INSTALLDIR}

make clean

make
make install

#freetype
cd ${SRCDIR}/${FREETYPE}
./configure --prefix=${INSTALLDIR}

make clean

make
make install

#libidn
cd ${SRCDIR}/${LIBIDN}
./configure --with-iconv-prefix=${INSTALLDIR} --prefix=${INSTALLDIR}

make clean

make
make install

#cURL
cd ${SRCDIR}/${CURL}
./configure --with-ssl=${INSTALLDIR} --with-zlib=${INSTALLDIR}
–with-libidn=${INSTALLDIR} --enable-ipv6 --enable-cookies
–enable-crypto-auth --prefix=${INSTALLDIR}

make clean

make
make install

c-client

cd ${SRCDIR}/${CCLIENT_DIR}
make ldb

Install targets are for wusses!

cp c-client/c-client.a ${INSTALLDIR}/lib/libc-client.a
cp c-client/*.h ${INSTALLDIR}/include

#libevent
cd ${SRCDIR}/${LIBEVENT}
./configure --prefix=${INSTALLDIR}
#make clean
make
make install

#PHP 5
cd ${SRCDIR}/${PHP5}
./configure ${PHPFEATURES}

make clean

make
make install

#copy config file
mkdir -p ${INSTALLDIR}/etc/php5/${DOMAIN};
cp ${SRCDIR}/${PHP5}/php.ini-dist ${INSTALLDIR}/etc/php5/${DOMAIN}/php.ini

#copy PHP CGI
mkdir -p ${HOME}/${DOMAIN}/cgi-bin
chmod 0755 ${HOME}/${DOMAIN}/cgi-bin
cp ${INSTALLDIR}/bin/php ${HOME}/${DOMAIN}/cgi-bin/php.cgi
echo ---------- INSTALL COMPLETE! ----------

This script install the M4, LIBTOOL, AUTOCONF and AUTOMAKE before install the PHP and other libraries.

After I installed the libssh2 (http://www.php.net/manual/en/ref.ssh2.php) adding the option “–prefix=$HOME/libssh2” because without this option appear an error of permission denied when the make try write the file in folder of system. The other problem was:

make[1]: Entering directory /home/.mowse/mydomain/temp/libssh2-0.14/src' gcc -o channel.o channel.c -c -g -O2 /usr/include -I/usr/include -Wall -I../include/ -fPIC gcc: cannot specify -o with -c or -S and multiple compilations make[1]: *** [channel.o] Error 1 make[1]: Leaving directory/home/.mowse/mydomain/temp/libssh2-0.14/src’
make: *** [all] Error 1

but I solve it running a script to change the options of make (cannot specify -o with -c or -S and multiple compilations).

Finally, I tried to install the PECL/ssh2 extension running “phpize && ./configure --with-ssh2 && make”. But appear the same error:

Configuring for:
PHP Api Version: 20020918
Zend Module Api No: 20020429
Zend Extension Api No: 20050606
Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF
environment variable is set correctly and then rerun this script.

Then I tried change the PHP_AUTOCONF to point $HOME/php5/bin/autoconf but don’t solved!

I am desperate. I really need install the extension pecl/ssh2 with php. Anybody help me PLEASE!!!


#4

You’ll want to follow a similar approach to the way the Suhosin install I submitted recently in the wiki works.

Basically, you need to compile autoconf and automake, install them into the source directory, and then compile ssh2 so that it’s aware of those locations. You’re at least on the right track though :wink:


Chips N Cheese - Custom PHP installs and the like!


#5

I got your script to install Suhosin and change it adding the follow lines:

Section "User Configuration Options"
subsection “What features do you want enabled?”

LIBSSH2FEATURES="–prefix=${INSTALLDIR}“
SSH2FEATURES=”–prefix=${INSTALLDIR} --with-ssh2"

I added code to download the libssh2 and ssh2.
I added code to extract the files downloaded.
After code to compile and install Suhosin, I added the follow code:

#LIBSSH2
cd ${SRCDIR}/${LIBSSH2}

to fix the error (cannot specify -o with -c or -S and multiple compilations)

find . -name Makefile.in -exec
perl -pi.bak -e ‘s/$(CC)\s±o\s+[\w_-]+?.o/$(CC)/’ {} ;

compile and install

./configure ${LIBSSH2FEATURES}

make clean

nice -n ${NICE} make

#SSH2
cd ${SRCDIR}/${SSH2}
$PHP_PREFIX/phpize
./configure ${SSH2FEATURES}

make clean

nice -n ${NICE} make

but when script run “./configure ${SSH2FEATURES}” appear the follow error:

checking for grep that handles long lines and -e… /bin/grep
checking for egrep… /bin/grep -E
checking for a sed that does not truncate output… /bin/sed
checking for gcc… gcc
checking for C compiler default output file name… a.out
checking whether the C compiler works… yes
checking whether we are cross compiling… no
checking for suffix of executables…
checking for suffix of object files… o
checking whether we are using the GNU C compiler… yes
checking whether gcc accepts -g… yes
checking for gcc option to accept ISO C89… none needed
checking whether gcc and cc understand -c and -o together… yes
checking if compiler supports -R… no
checking if compiler supports -Wl,-rpath,… yes
checking build system type… i686-pc-linux-gnu
checking host system type… i686-pc-linux-gnu
checking target system type… i686-pc-linux-gnu
checking for PHP prefix… /home/mydomain/php5
checking for PHP includes… -I/home/mydomain/php5/include/php -I/home/mydomain/php5/include/php/main -I/home/mydomain/php5/include/php/TSRM -I/home/mydomain/php5/include/php/Zend -I/home/mydomain/php5/include/php/ext -I/home/mydomain/php5/include/php/ext/date/lib
checking for PHP extension directory… /home/mydomain/php5/lib/php/extensions/no-debug-non-zts-20060613
checking for PHP installed headers prefix… /home/mydomain/php5/include/php
checking for re2c… no
configure: WARNING: You will need re2c 0.9.11 or later if you want to regenerate PHP parsers.
checking for gawk… gawk
checking for ssh2 support… yes, shared
checking for ssh2 files in default path… not found
configure: error: The required libssh2 library was not found. You can obtain that package from http://sourceforge.net/projects/libssh2/

but I installed libssh2. I googled many times but don’t found any solution.

PLEASE, ANYBODY HELP ME!!!