centos7 php如何安装redis扩展

1.下载redis扩展包

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

2.解压

tar -zxf redis-5.2.0.tgz

3.切换到解压目录

cd redis-5.2.0

3.运行phpize

/usr/local/php/bin/phpize

4.使用 ./configure 进行配置

./configure --with-php-config=/usr/local/php/bin/php-config

5.安装

make && make install

安装成功会出现下面这行,这就是扩展所在的路径

Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20180731/

6.修改php.ini,把redis扩展加进去

vim /usr/local/php/etc/php.ini

把下面这两行加到php.ini里面

extension_dir = /usr/local/php/lib/php/extensions/no-debug-non-zts-20180731/
extension = redis.so

7.重启一下php,这样扩展就安装好了

kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid`

8.查看扩展是否安装成功,如果看到redis就说明安装成功了

php -m

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: