zoukankan      html  css  js  c++  java
  • centos8平台php7.4.2安装phpredis实现对redis的访问

    一,下载phpredis

    1,官方下载地址:

    https://github.com/phpredis/phpredis/releases

    2,wget下载

    [root@yjweb source]# wget https://github.com/phpredis/phpredis/archive/5.2.0.tar.gz

    说明:刘宏缔的架构森林是一个专注架构的博客,地址:https://www.cnblogs.com/architectforest

             对应的源码可以访问这里获取: https://github.com/liuhongdi/

     说明:作者:刘宏缔 邮箱: 371125307@qq.com

    二,解压:

    [root@yjweb source]# tar -zxvf 5.2.0.tar.gz 

    三,安装phpredis

    1,phpize

    说明:phpize的作用:检查php环境,为扩展生成configure文件

    [root@yjweb source]# cd phpredis-5.2.0/
    [root@yjweb phpredis-5.2.0]# /usr/local/soft/php7/bin/phpize
    Configuring for:
    PHP Api Version:         20190902
    Zend Module Api No:      20190902
    Zend Extension Api No:   320190902

    2,配置,要指定php-config的所在路径

    [root@yjweb phpredis-5.2.0]# ./configure --with-php-config=/usr/local/soft/php7/bin/php-config

    3,安装

    [root@yjweb phpredis-5.2.0]# make && make install;

    说明:注意安装完成后提示的路径:

    Installing shared extensions:     /usr/local/soft/php7/lib/php/extensions/no-debug-non-zts-20190902/

    我们在添加模块时要用到

    四,配置php.ini,引入redis模块

    [root@yjweb phpredis-5.2.0]# vi /usr/local/soft/php7/etc/php.ini

    添加一行:

    extension=/usr/local/soft/php7/lib/php/extensions/no-debug-non-zts-20190902/redis.so 

    五,重启服务,检查安装是否成功

    1,重启

    [root@yjweb phpredis-5.2.0]# systemctl stop php-fpm
    [root@yjweb phpredis-5.2.0]# systemctl start php-fpm 

    2,从浏览器检查安装是否成功

    在documentroot目录下,增加一个phpinfo.php页面,

    从浏览器访问,从phpinfo页面搜索 redis,

    找到后说明安装成功

    phpinfo.php页面的代码:

    <?php
    phpinfo();
    ?>

    3,从命令行检查安装是否成功

    看到redis模块,说明安装成功

    [root@yjweb phpredis-5.2.0]# /usr/local/soft/php7/bin/php --ri redis
    
    redis
    
    Redis Support => enabled
    Redis Version => 5.2.0
    Redis Sentinel Version => 0.1
    Available serializers => php, json
    Directive => Local Value => Master Value
    redis.arrays.algorithm => no value => no value
    redis.arrays.auth => no value => no value
    redis.arrays.autorehash => 0 => 0
    redis.arrays.connecttimeout => 0 => 0
    redis.arrays.distributor => no value => no value
    redis.arrays.functions => no value => no value
    redis.arrays.hosts => no value => no value
    redis.arrays.index => 0 => 0
    redis.arrays.lazyconnect => 0 => 0
    redis.arrays.names => no value => no value
    redis.arrays.pconnect => 0 => 0
    redis.arrays.previous => no value => no value
    redis.arrays.readtimeout => 0 => 0
    redis.arrays.retryinterval => 0 => 0
    redis.arrays.consistent => 0 => 0
    redis.clusters.cache_slots => 0 => 0
    redis.clusters.auth => no value => no value
    redis.clusters.persistent => 0 => 0
    redis.clusters.read_timeout => 0 => 0
    redis.clusters.seeds => no value => no value
    redis.clusters.timeout => 0 => 0
    redis.pconnect.pooling_enabled => 1 => 1
    redis.pconnect.connection_limit => 0 => 0
    redis.session.locking_enabled => 0 => 0
    redis.session.lock_expire => 0 => 0
    redis.session.lock_retries => 10 => 10
    redis.session.lock_wait_time => 2000 => 2000

    六,查看本地centos的版本

    [webop@yjweb ~]$ cat /etc/redhat-release
    CentOS Linux release 8.0.1905 (Core) 
  • 相关阅读:
    JavaScript 格式化数字
    浅析C#中单点登录的原理和使用
    从银行转账失败到分布式事务:总结与思考
    计算机网络资料
    阿里巴巴Java开发规约插件p3c详细教程及使用感受
    程序员如何打造属于自己的云笔记服务
    sql server2016里面的json功能
    mac pro 开启三只滑动选中文本
    技术网站
    idea gradle项目导入
  • 原文地址:https://www.cnblogs.com/architectforest/p/12456445.html
Copyright © 2011-2022 走看看