a. libssh2 설치
wget http://surfnet.dl.sourceforge.net/sourceforge/libssh2/libssh2-0.14.tar.gz
tar -zxvf libssh2-0.14.tar.gz
cd libssh2-0.14/
./configure
make all install
설치 후 ldconfig 를 하여도 라이브러리가 올라오지 않는다면 make all install을 한번 더 해주면 잘 된다(..)
b. pecl module 설치
pecl install -f ssh2
--- 작업 결과는 log를 참고 하자;
c. php.ini 수정
dynamic module에
extension=ssh2.so 를 추가하자.
그러나 ssl2 관련 모듈이 phpinfo()를 통해서 모듈이 추가 되었는지 확인해주자.
위와 같이 추가 되지 않을 경우 전체 경로를 삽입하여주면은 잘 올라오드라..
extension=/usr/local/lib/php/extensions/no-debug-non-zts-20020429/ssh2.so
d. 나머지 사용법은 php메뉴얼을 참고 하자.
http://kr2.php.net/manual/kr/function.ssh2-shell.php
[root@svr140 src]# pecl install -f ssh2
WARNING: failed to download pecl.php.net/ssh2 within preferred state "stable", will instead download version 0.10, stability "beta"
WARNING: channel "pear.php.net" has updated its protocols, use "channel-update pear.php.net" to update
downloading ssh2-0.10.tgz ...
Starting to download ssh2-0.10.tgz (22,187 bytes)
........done: 22,187 bytes
5 source files, building
running: phpize
Configuring for:
PHP Api Version: 20020918
Zend Module Api No: 20020429
Zend Extension Api No: 20050606
building in /var/tmp/pear-build-root/ssh2-0.10
running: /tmp/pear/cache/ssh2-0.10/configure
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking for egrep... 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 ANSI C... 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 for PHP prefix... /usr/local
checking for PHP includes... -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend
checking for PHP extension directory... /usr/local/lib/php/extensions/no-debug-non-zts-20020429
checking for re2c... exit 0;
checking for gawk... gawk
checking for ssh2 support... yes, shared
checking for ssh2 files in default path... found in /usr/local
checking for libssh2_banner_set in -lssh2... yes
checking for libssh2_channel_forward_listen_ex in -lssh2... yes
checking for libssh2_userauth_hostbased_fromfile_ex in -lssh2... yes
checking for libssh2_poll in -lssh2... yes
checking for libssh2_publickey_init in -lssh2... yes
checking for ld used by GCC... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for /usr/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm -B
checking whether ln -s works... yes
checking how to recognise dependent libraries... pass_all
checking command to parse /usr/bin/nm -B output... ok
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking for ranlib... ranlib
checking for strip... strip
checking for objdir... .libs
checking for gcc option to produce PIC... -fPIC
checking if gcc PIC flag -fPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.lo... yes
checking if gcc supports -fno-rtti -fno-exceptions... no
checking whether the linker (/usr/bin/ld) supports shared libraries... yes
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking dynamic linker characteristics... GNU/Linux ld.so
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
checking whether -lc should be explicitly linked in... no
creating libtool
configure: creating ./config.status
config.status: creating config.h
running: make
/bin/sh /var/tmp/pear-build-root/ssh2-0.10/libtool --mode=compile gcc -I. -I/tmp/pear/cache/ssh2-0.10 -DPHP_ATOM_INC -I/var/tmp/pear-build-root/ssh2-0.10/include -I/var/tmp/pear-build-root/ssh2-0.10/main -I/tmp/pear/cache/ssh2-0.10 -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/cache/ssh2-0.10/ssh2.c -o ssh2.lo
gcc -I. -I/tmp/pear/cache/ssh2-0.10 -DPHP_ATOM_INC -I/var/tmp/pear-build-root/ssh2-0.10/include -I/var/tmp/pear-build-root/ssh2-0.10/main -I/tmp/pear/cache/ssh2-0.10 -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/cache/ssh2-0.10/ssh2.c -fPIC -DPIC -o ssh2.lo
/tmp/pear/cache/ssh2-0.10/ssh2.c: In function 'zif_ssh2_methods_negotiated':
/tmp/pear/cache/ssh2-0.10/ssh2.c:483: warning: assignment discards qualifiers from pointer target type
/tmp/pear/cache/ssh2-0.10/ssh2.c:484: warning: assignment discards qualifiers from pointer target type
/tmp/pear/cache/ssh2-0.10/ssh2.c:485: warning: assignment discards qualifiers from pointer target type
/tmp/pear/cache/ssh2-0.10/ssh2.c:486: warning: assignment discards qualifiers from pointer target type
/tmp/pear/cache/ssh2-0.10/ssh2.c:487: warning: assignment discards qualifiers from pointer target type
/tmp/pear/cache/ssh2-0.10/ssh2.c:488: warning: assignment discards qualifiers from pointer target type
/tmp/pear/cache/ssh2-0.10/ssh2.c:489: warning: assignment discards qualifiers from pointer target type
/tmp/pear/cache/ssh2-0.10/ssh2.c:490: warning: assignment discards qualifiers from pointer target type
/tmp/pear/cache/ssh2-0.10/ssh2.c:491: warning: assignment discards qualifiers from pointer target type
/tmp/pear/cache/ssh2-0.10/ssh2.c:492: warning: assignment discards qualifiers from pointer target type
/tmp/pear/cache/ssh2-0.10/ssh2.c: In function 'zif_ssh2_fingerprint':
/tmp/pear/cache/ssh2-0.10/ssh2.c:536: warning: assignment discards qualifiers from pointer target type
/tmp/pear/cache/ssh2-0.10/ssh2.c: In function 'zif_ssh2_publickey_add':
/tmp/pear/cache/ssh2-0.10/ssh2.c:985: warning: pointer targets in passing argument 3 of 'zend_hash_get_current_key_ex' differ in signedness
/tmp/pear/cache/ssh2-0.10/ssh2.c:985: warning: pointer targets in passing argument 4 of 'zend_hash_get_current_key_ex' differ in signedness
/tmp/pear/cache/ssh2-0.10/ssh2.c:1026: warning: pointer targets in passing argument 2 of 'libssh2_publickey_add_ex' differ in signedness
/tmp/pear/cache/ssh2-0.10/ssh2.c:1026: warning: pointer targets in passing argument 4 of 'libssh2_publickey_add_ex' differ in signedness
/tmp/pear/cache/ssh2-0.10/ssh2.c: In function 'zif_ssh2_publickey_remove':
/tmp/pear/cache/ssh2-0.10/ssh2.c:1060: warning: pointer targets in passing argument 2 of 'libssh2_publickey_remove_ex' differ in signedness
/tmp/pear/cache/ssh2-0.10/ssh2.c:1060: warning: pointer targets in passing argument 4 of 'libssh2_publickey_remove_ex' differ in signedness
/tmp/pear/cache/ssh2-0.10/ssh2.c: In function 'zif_ssh2_publickey_list':
/tmp/pear/cache/ssh2-0.10/ssh2.c:1097: warning: pointer targets in passing argument 4 of 'add_assoc_stringl_ex' differ in signedness
/tmp/pear/cache/ssh2-0.10/ssh2.c:1098: warning: pointer targets in passing argument 4 of 'add_assoc_stringl_ex' differ in signedness
/bin/sh /var/tmp/pear-build-root/ssh2-0.10/libtool --mode=compile gcc -I. -I/tmp/pear/cache/ssh2-0.10 -DPHP_ATOM_INC -I/var/tmp/pear-build-root/ssh2-0.10/include -I/var/tmp/pear-build-root/ssh2-0.10/main -I/tmp/pear/cache/ssh2-0.10 -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/cache/ssh2-0.10/ssh2_fopen_wrappers.c -o ssh2_fopen_wrappers.lo
gcc -I. -I/tmp/pear/cache/ssh2-0.10 -DPHP_ATOM_INC -I/var/tmp/pear-build-root/ssh2-0.10/include -I/var/tmp/pear-build-root/ssh2-0.10/main -I/tmp/pear/cache/ssh2-0.10 -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/cache/ssh2-0.10/ssh2_fopen_wrappers.c -fPIC -DPIC -o ssh2_fopen_wrappers.lo
/tmp/pear/cache/ssh2-0.10/ssh2_fopen_wrappers.c: In function 'php_ssh2_shell_open':
/tmp/pear/cache/ssh2-0.10/ssh2_fopen_wrappers.c:392: warning: pointer targets in passing argument 3 of 'zend_hash_get_current_key_ex' differ in signedness
/tmp/pear/cache/ssh2-0.10/ssh2_fopen_wrappers.c:392: warning: pointer targets in passing argument 4 of 'zend_hash_get_current_key_ex' differ in signedness
/tmp/pear/cache/ssh2-0.10/ssh2_fopen_wrappers.c: In function 'php_ssh2_exec_command':
/tmp/pear/cache/ssh2-0.10/ssh2_fopen_wrappers.c:635: warning: pointer targets in passing argument 3 of 'zend_hash_get_current_key_ex' differ in signedness
/tmp/pear/cache/ssh2-0.10/ssh2_fopen_wrappers.c:635: warning: pointer targets in passing argument 4 of 'zend_hash_get_current_key_ex' differ in signedness
/bin/sh /var/tmp/pear-build-root/ssh2-0.10/libtool --mode=compile gcc -I. -I/tmp/pear/cache/ssh2-0.10 -DPHP_ATOM_INC -I/var/tmp/pear-build-root/ssh2-0.10/include -I/var/tmp/pear-build-root/ssh2-0.10/main -I/tmp/pear/cache/ssh2-0.10 -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/cache/ssh2-0.10/ssh2_sftp.c -o ssh2_sftp.lo
gcc -I. -I/tmp/pear/cache/ssh2-0.10 -DPHP_ATOM_INC -I/var/tmp/pear-build-root/ssh2-0.10/include -I/var/tmp/pear-build-root/ssh2-0.10/main -I/tmp/pear/cache/ssh2-0.10 -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/cache/ssh2-0.10/ssh2_sftp.c -fPIC -DPIC -o ssh2_sftp.lo
/bin/sh /var/tmp/pear-build-root/ssh2-0.10/libtool --mode=link gcc -DPHP_ATOM_INC -I/var/tmp/pear-build-root/ssh2-0.10/include -I/var/tmp/pear-build-root/ssh2-0.10/main -I/tmp/pear/cache/ssh2-0.10 -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include -DHAVE_CONFIG_H -g -O2 -o ssh2.la -export-dynamic -avoid-version -prefer-pic -module -rpath /var/tmp/pear-build-root/ssh2-0.10/modules ssh2.lo ssh2_fopen_wrappers.lo ssh2_sftp.lo -Wl,-rpath,/usr/local/lib -L/usr/local/lib -lssh2
mkdir .libs
rm -fr .libs/ssh2.la .libs/ssh2.* .libs/ssh2.*
(cd . && ln -s ssh2.lo ssh2.o)
(cd . && ln -s ssh2_fopen_wrappers.lo ssh2_fopen_wrappers.o)
(cd . && ln -s ssh2_sftp.lo ssh2_sftp.o)
gcc -shared ssh2.lo ssh2_fopen_wrappers.lo ssh2_sftp.lo -L/usr/local/lib -lssh2 -Wl,-rpath -Wl,/usr/local/lib -Wl,-soname -Wl,ssh2.so -o .libs/ssh2.so
creating ssh2.la
(cd .libs && rm -f ssh2.la && ln -s ../ssh2.la ssh2.la)
/bin/sh /var/tmp/pear-build-root/ssh2-0.10/libtool --mode=install cp ./ssh2.la /var/tmp/pear-build-root/ssh2-0.10/modules
cp ./.libs/ssh2.so /var/tmp/pear-build-root/ssh2-0.10/modules/ssh2.so
cp ./.libs/ssh2.lai /var/tmp/pear-build-root/ssh2-0.10/modules/ssh2.la
PATH="$PATH:/sbin" ldconfig -n /var/tmp/pear-build-root/ssh2-0.10/modules
----------------------------------------------------------------------
Libraries have been installed in:
/var/tmp/pear-build-root/ssh2-0.10/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.
(It is safe to ignore warnings about tempnam and tmpnam).
running: make INSTALL_ROOT="/var/tmp/pear-build-root/install-ssh2-0.10" install
Installing shared extensions: /var/tmp/pear-build-root/install-ssh2-0.10/usr/local/lib/php/extensions/no-debug-non-zts-20020429/
running: find "/var/tmp/pear-build-root/install-ssh2-0.10" -ls
255752 4 drwxr-xr-x 3 root root 4096 Apr 10 11:05 /var/tmp/pear-build-root/install-ssh2-0.10
255777 4 drwxr-xr-x 3 root root 4096 Apr 10 11:05 /var/tmp/pear-build-root/install-ssh2-0.10/usr
255778 4 drwxr-xr-x 3 root root 4096 Apr 10 11:05 /var/tmp/pear-build-root/install-ssh2-0.10/usr/local
255779 4 drwxr-xr-x 3 root root 4096 Apr 10 11:05 /var/tmp/pear-build-root/install-ssh2-0.10/usr/local/lib
255780 4 drwxr-xr-x 3 root root 4096 Apr 10 11:05 /var/tmp/pear-build-root/install-ssh2-0.10/usr/local/lib/php
255781 4 drwxr-xr-x 3 root root 4096 Apr 10 11:05 /var/tmp/pear-build-root/install-ssh2-0.10/usr/local/lib/php/extensions
255782 4 drwxr-xr-x 2 root root 4096 Apr 10 11:05 /var/tmp/pear-build-root/install-ssh2-0.10/usr/local/lib/php/extensions/no-debug-non-zts-20020429
255776 144 -rwxr-xr-x 1 root root 139590 Apr 10 11:05 /var/tmp/pear-build-root/install-ssh2-0.10/usr/local/lib/php/extensions/no-debug-non-zts-20020429/ssh2.so
Build process completed successfully
Installing '/usr/local/lib/php/extensions/no-debug-non-zts-20020429/ssh2.so'
install ok: channel://pear.php.net/ssh2-0.10