Linux 安装phpredis扩展

这篇博客介绍了如何在已经使用yum安装了PHP环境的Linux服务器上,手动安装并配置phpredis扩展。过程中提到了需要phpize和php-config,以及安装igbinary作为前提。在遇到错误和依赖问题后,通过一步步解决,最终成功安装并重启服务。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

背景:php环境使用yum安装的,不需要安装redis,只需要phpredis扩展

一、调试phpize

二、安装igbinary 

三、安装phpredis

四、重启

走到哪里都不要忘了官网 https://github.com/phpredis/phpredis


开始使用yum install php-redis

看到有人推荐

wget http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
yum install php-redis


无果,一直error,忘记截图了


只有看到 http://www.osyunwei.com/archives/7210.html 

因为服务器用yum安装的,感觉不能make(本人新手),看到很多的资料以后,最终决定此方法是ok的


但是需要准备两个文件,phpize ,php-config

查找两个文件的位置

whereis phpize

whereis php-config

发现没有php-config


于是运行phpize 或者/usr/bin/phpize,此时报错再次报错

# phpize
Can't find PHP headers in /usr/include/php
The php-devel package is required for use of this command.

运行
yum install php-devel

此时,php-config存在,./configure 也可以运行了


安装phpredis前,必须安装igbinary 否则又是各种错误

checking for igbinary includes... configure: error: Cannot find igbinary.h


此时就是提醒需要安装igbinary,中间可能遇到很多的问题,缺少各种各样的扩展,此处整理一下代码

114  wget https://github.com/nicolasff/phpredis/archive/2.2.4.tar.gz

  116  mv 2.2.4.tar.gz /usr/local/src/

  118  cd /usr/local/src/

  120  tar zxvf 2.2.4.tar.gz 

  122  cd phpredis-2.2.4/

  126  phpize
  127  yum install php-pear
  128  yum install php-devel
  129  phpize
  130  whereis php-config
  
  #此时停止了phpredis安装,开始安装igbinary
  
  147  wget http://pecl.php.net/get/igbinary-1.1.1.tgz

  149  mv igbinary-1.1.1.tgz /usr/local/src/
	   cd /usr/local/src/
  152  tar -xzvf igbinary-1.1.1.tgz 
  153  cd igbinary-1.1.1
  154  phpize 
  155  ./configure 
  156  make
  157  make install
  
  #安装igbinary后,安装redis
    
  160  cd phpredis-2.2.4/
  161  phpize 
  162  ./configure --enable-redis-igbinary#貌似(./configure --enable-redis-igbinary --with-php-config=/usr/bin/php-config)这样也可以
  163  make
  164  make install


最后在php.ini中添加

extension=igbinary.so
extension=redis.so

重启


重点学会用yum安装的环境后,

使用phpize

./configure 

make && make install

这个编译模式


加油,菜菜

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值