安装PHP的Redis 扩展

  • Post author:
  • Post published:10月 10, 2019
  • Post category:PHP
  • Post comments:0评论

前提:服务器安装好 Redis,这里不做详细说明 (centos7 可以执行 yum install redis 进行安装)

https://pecl.php.net PHP的 PECL 官方库中搜索并查看是否为对应PHP版本 的Redis,将其他下载

# 下载源码
wget https://pecl.php.net/get/redis-5.0.2.tgz

# 解压源码
tar zxvf redis-5.0.2.tgz

# 进入已解压的源码目录
cd redis-5.0.2.tgz

# 执行 phpize 生成配置文件脚本 configure 
phpize

#  查找php-config 的位置 
 find / -name php-config 

# 关联 php-config 路径 执行 configure 脚本 
 ./configure --with-php-config=/usr/local/php/bin/php-config 

# 编译源码
make

# 编译生成 .so 模块
make install

# 在PHP的配置文件中加入
extension=redis.so

# 能看到 redis 表示成功安装
php -m

# nginx 和 apache 要重启,下面以 Nginx 作为示例
systemctl restart php-fpm

发表评论