centos7 php5.6 php-redis扩展安装

2021-05-13  本文已影响0人  街头民工

这里安装的php-redis扩展是phpredis-4.0.2版本

#下载扩展包
wget https://github.com/phpredis/phpredis/archive/4.0.2.tar.gz
tar -zxvf 4.0.2.tar.gz
cd phpredis-4.0.2
#查看php-config文件在什么位置
whereis php-config
image.png
#运行 phpize 生成configure 文件
phpize

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

make && make install

#将redis.so添加到php.ini中 如果不知道 php.ini 在什么位置可以 运行 whereis php.ini
echo 'extension=redis.so' >> /etc/php.ini

#重启php-fpm
systemctl restart php-fpm.service
<?php
    //连接本地的 Redis 服务
   $redis = new Redis();
   $redis->connect('127.0.0.1', 6379);
   $redis->auth('123456');
   echo "Connection to server sucessfully";
   //查看服务是否运行
   echo "Server is running: " . $redis->ping();
image.png

如果容器填写的是外网ip 一定要记得去打开安全组端口

上一篇 下一篇

猜你喜欢

热点阅读