본문 바로가기

기타

[Redis] PHP redis 확장(Extension)을 설치하는 방법

728x90

PHP redis 확장(Extension)을 설치하는 방법

redis 설치

$ yum -y install gcc gcc-c++ make jemalloc tcl

$ yum install redis

$ systemctl --now enable redis

$ redis-cli -h 127.0.0.1 -p 6379 ping

redis extension 모듈 설치

phpredis 패키지 다운로드

$ wget https://github.com/phpredis/phpredis/archive/develop.zip

$ unzip develop.zip

$ cd phpredis-develop

PHP 확장 컴파일, 구성 환경, 컴파일

#PHP 확장 컴파일
$ /usr/local/php/bin/phpize

#구성 환경
$ ./configure --with-php-config=/usr/local/php/bin/php-config

#컴파일
$ make
$ make install
---output--
...
----------------------------------------------------------------------
Installing shared extensions: /usr/local/php/lib/php/extensions/debug-zts-20180731/

php 확장 모듈 디렉토리 확인

$ /usr/local/php/bin/php -i | grep extension_dir
extension_dir => /usr/local/php/lib/php/extensions/debug-zts-20180731/ => /usr/local/php/lib/php/extensions/debug-zts-20180731/
sqlite3.extension_dir => no value => no value

php.ini 편집

$ echo "extension=redis.so" >> /usr/local/apache2/conf/php.ini

redis 모듈 확인

$ /usr/local/php/bin/php -m | grep redis

$ /usr/local/php/bin/php -i | grep redis

$ /usr/local/php/bin/php -r "phpinfo();" | grep redis

아파치 재기동

$ /usr/local/apache2/bin/apachectl restart

phpredis : https://github.com/phpredis/phpredis

728x90