PHP의 확장 모듈인 SSH2를 설치하는 방법입니다.

최신 버전을 http://pecl.php.net/package/ssh2 에서 다운로드 합니다.

[[email protected] ~]# wget http://pecl.php.net/get/ssh2-0.12.tgz
[[email protected] ~]# tar xzvf ssh2-0.12.tgz
[[email protected] ~]# cd ssh2-0.12
[[email protected] ~]# /usr/local/php-5.3.21-fpm/bin/phpize
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626
configure.in:3: warning: prefer named diversions
configure.in:3: warning: prefer named diversions

 

컴파일 및 설치 합니다.

[[email protected] ~]# ./configure –with-php-config=/usr/local/php-5.3.21-fpm/bin/php-config
[[email protected] ~]# make ; make install
/bin/bash /usr/local/src/ssh2-0.12/libtool –mode=install cp ./ssh2.la /usr/local/src/ssh2-0.12/modules
cp ./.libs/ssh2.so /usr/local/src/ssh2-0.12/modules/ssh2.so
cp ./.libs/ssh2.lai /usr/local/src/ssh2-0.12/modules/ssh2.la
PATH=”$PATH:/sbin” ldconfig -n /usr/local/src/ssh2-0.12/modules
———————————————————————-
Libraries have been installed in:
/usr/local/src/ssh2-0.12/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the -LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the
LD_LIBRARY_PATH’ environment variable
during execution
– add LIBDIR to the LD_RUN_PATH' environment variable
during linking
- use the
-Wl,–rpath -Wl,LIBDIR’ linker flag
– have your system administrator add LIBDIR to `/etc/ld.so.conf’

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
———————————————————————-

Build complete.
Don’t forget to run ‘make test’.

Installing shared extensions: /usr/local/php-5.3.21-fpm/lib/php/extensions/no-debug-non-zts-20090626/

 

php.ini에 내용 추가

[[email protected] ~]# echo ‘[ssh2]’ >> /usr/local/php-5.3.21-fpm/etc/php.ini
[[email protected] ~]# echo ‘extension=ssh2.so’ >> /usr/local/php-5.3.21-fpm/etc/php.ini
[[email protected] ~]# echo ‘/usr/local/php-5.3.21-fpm/lib/php/extensions/no-debug-non-zts-20090626/’ >> /usr/local/php-5.3.21-fpm/etc/php.ini

 

phpinfo 확인

[[email protected] ~]# echo ‘<?php phpinfo(); ?>’ > /home/ruo91/public_html/phpinfo.php
[[email protected] ~]# php /home/ruo91/public_html/phpinfo.php | grep ssh2
Registered PHP Streams => https, ftps, compress.zlib, compress.bzip2, php, file, glob, data, http, ftp, zip, phar, ssh2.shell, ssh2.exec, ssh2.tunnel, ssh2.scp, ssh2.sftp
libSSH Version => libssh2/1.2.6
ssh2
libssh2 version => 1.2.6
banner => SSH-2.0-libssh2_1.2.6
OLDPWD => /usr/local/src/ssh2-0.12
_SERVER[“OLDPWD”] => /usr/local/src/ssh2-0.12
_ENV[“OLDPWD”] => /usr/local/src/ssh2-0.12

 

또는 Web browser에서 확인
php-ssh2
php-ssh2_2