운영체제/리눅스(CentOS)

php 5.3에 phpredis 컴파일설치

마루의 일상 2021. 12. 3. 13:58
728x90
반응형

설치할 서버에 php환경

 

설치환경
php 5.3.3

 

redis-2.2.7 파일을 다운로드합니다.

wget http://pecl.php.net/get/redis-2.2.7.tgz
cs

다운로드한 파일을 압축 풀어 줍니다.

압축 푼 폴더로 이동후 /usr/local/php/bin/phpize 실행해 줍니다.

(phpize는 php의 확장 모듈을 올리는 유틸이다.)

tar -zxvf redis-2.2.7.tgz 
package.xml
redis-2.2.7/tests/array-tests.php
redis-2.2.7/tests/memory.php
redis-2.2.7/tests/mkring.sh
redis-2.2.7/tests/test.php
redis-2.2.7/tests/TestRedis.php
redis-2.2.7/README.markdown
redis-2.2.7/arrays.markdown
redis-2.2.7/CREDITS
redis-2.2.7/COPYING
redis-2.2.7/config.m4
redis-2.2.7/config.w32
redis-2.2.7/common.h
redis-2.2.7/library.c
redis-2.2.7/library.h
redis-2.2.7/php_redis.h
redis-2.2.7/redis_array.c
redis-2.2.7/redis_array.h
redis-2.2.7/redis_array_impl.c
redis-2.2.7/redis_array_impl.h
redis-2.2.7/redis.c
redis-2.2.7/redis_session.c
redis-2.2.7/redis_session.h
[root@localhost src]# cd redis-2.2.7
[root@localhost redis-2.2.7]# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
Zend Extension Api No:   220090626
cs

./configure --with-php-config=/usr/local/php/bin/php-config 명령을 실행해 줍니다.

--with-php-config는 php설치 환경에 따라 달라질 수 있습니다.

[root@localhost redis-2.2.7]# ./configure --with-php-config=/usr/local/php/bin/php-config
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 cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
 
.
 
.
 
.
 
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
 
creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
cs

 

make 실행 후 make install을 실행 해주 줍니다.

그러면 설치된 경로가 나오는데 복사해 줍니다.

[root@localhost redis-2.2.7]# make
/bin/sh /usr/local/src/redis-2.2.7/libtool --mode=compile cc  -I. -I/usr/local/src/redis-2.2.7 -DPHP_ATOM_INC -I/usr/local/src/redis-2.2.7/include -I/usr/local/src/redis-2.2.7/main -I/usr/local/src/redis-2.2.7 -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib  -DHAVE_CONFIG_H  --O2   -/usr/local/src/redis-2.2.7/redis.c -o redis.lo 
mkdir .libs
 cc -I. -I/usr/local/src/redis-2.2.7 -DPHP_ATOM_INC -I/usr/local/src/redis-2.2.7/include -I/usr/local/src/redis-2.2.7/main -I/usr/local/src/redis-2.2.7 -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -DHAVE_CONFIG_H --O2 -/usr/local/src/redis-2.2.7/redis.c  -fPIC -DPIC -o .libs/redis.o
 
.
 
.
 
.
 
Libraries have been installed in:
   /usr/local/src/redis-2.2.7/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'.
 
[root@localhost redis-2.2.7]# make install
Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-zts-20090626/
cs

php.ini에 아래 문구를 추가해 줍고 아파치를 재시작해줍니다.

[redis]
extension=/usr/local/php/lib/php/extensions/no-debug-zts-20090626/redis.so


[root@localhost redis-2.2.7] apache restart
cs

설치가 완료되었습니다.

감사합니다.

728x90
반응형