linux安装php redis拓展


当前tp等框架都很经常使用redis缓存,特别使用lnmp新安装后,默认是不支持 redis的,在linux服务器上需要安装redis拓展。

查看当前的redis拓展版本:php -r 'phpinfo();' |grep Redis

直接上流程:

下载安装

# wget https://github.com/phpredis/phpredis/archive/5.0.0.zip
# mv 5.0.0.zip phpredis-5.0.0.zip
# unzip phpredis-5.0.0.zip

# cd phpredis-5.0.0
# /usr/bin/phpize

# find / -name php-config

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

# make && make install

配置

输入php --ini找到ini路径,然后编辑,找到extension拓展最下面,新增

extension = redis

最后 service php-fpm restart 即可

重新查看php-redis拓展版本:php -r 'phpinfo();' |grep redis

其他版本:

  • phpredis-3.1.6.tar.gz

https://github.com/phpredis/phpredis/archive/3.1.6.tar.gz

  • phpredis-5.3.7 可以用在php81

https://github.com/phpredis/phpredis/archive/refs/tags/5.3.7.zip

配置lnmp的redis支持:"message": "not support: redis"

注意

  • 如果存在多个php版本,需要注意php-config和phpize路径,分享我的:
[root@fouryear ~]# find / -name php-config
/root/php-5.6.21/scripts/php-config
/root/php-7.4.10/scripts/php-config
/root/php-7.2.33/scripts/php-config
/usr/local/php/bin/php-config
/usr/local/php5/bin/php-config
/usr/local/php72/bin/php-config

[root@fouryear ~]# find / -name phpize
/root/php-5.6.21/scripts/phpize
/root/php-7.4.10/scripts/phpize
/root/php-7.2.33/scripts/phpize
/usr/local/php/bin/phpize
/usr/local/php5/bin/phpize
/usr/local/php72/bin/phpize

版权声明,转载请附上原文链接及本声明: https://blog.yongit.com/note/199477.html