关于我们

质量为本、客户为根、勇于拼搏、务实创新

< 返回新闻公共列表

Centos 7 安装PHP的redis扩展

发布时间:2019/9/23 9:49:52
香港云服务器

从https://pecl.php.net/package/redis   里面找到自己安装的Redis对应版本的redis

1、获取已经安装的Redis版本扩展我这边安装的是4.0.1版本

wget https://pecl.php.net/get/redis-4.0.1.tgz

2、解压

 tar -zxvf redis-4.0.1.tgz 

3、进入目录  配置到已安装的PHP对应位置

#cd redis-4.0.1#/usr/local/php/bin/phpize
#./configure --with-php-config=/usr/local/php/bin/php-config
#make && make install

4、修改php.ini 加入redis.so(Linux不认dll文件  不要添加也不要打开)

extension="redis.so"

5、然后重启PHP和nginx

/etc/init.d/php-fpm restart/usr/local/nginx/sbin/nginx -s reload

若出现

(error) DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified...

修改redis.conf

daemonize no
protected-mode no

然后加载配置启动  一定要加载配置

/usr/local/redis/src/redis-server redis.conf #这个是我的目录  找到自己安装的目录  替换掉就好了

访问地址  查看phpinfo();

image.png

可以找到redis扩展  就说明安装扩展成功了