Linux下php添加redis扩展

  1. 查看php版本

    # php -v
    
    如下:
    PHP 7.1.25 (cli) (built: Dec  6 2018 22:54:10) ( NTS )
    Copyright (c) 1997-2018 The PHP Group
    Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
        with Zend OPcache v7.1.25, Copyright (c) 1999-2018, by Zend Technologies
        with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans
    

    PHP 7.1.25 (cli) (built: Dec 6 2018 22:54:10) ( NTS )

  2. 列出所有的可以安装的php软件包列表

    # yum list|grep php71w*
    
    结果大致如下:
    | mod_php71w.x86_64                       7.1.25-1.w7                     @webtatic
    | php71w-bcmath.x86_64                    7.1.25-1.w7                     @webtatic
    | php71w-xmlrpc.x86_64                    7.1.25-1.w7                     @webtatic
    | php71w-pecl-libsodium.x86_64            1.0.6-1.w7                      webtatic
    | php71w-pecl-memcached.x86_64            3.0.4-1.w7                      webtatic
    | php71w-pecl-mongodb.x86_64              1.4.1-1.w7                      webtatic
    | php71w-pecl-redis.x86_64                3.1.6-1.w7                      webtatic
    
    找到 redis 扩展
    | php71w-pecl-redis.x86_64                3.1.6-1.w7                      webtatic
    

    如果列出的时候出现如下:

    Another app is currently holding the yum lock; waiting for it to exit...
      The other application is: yum
        Memory : 132 M RSS (603 MB VSZ)
        Started: Thu Jan 17 11:27:00 2019 - 10:51 ago
        State  : Traced/Stopped, pid: 18807
    意思是另一个应用程序正在持有yum锁;正在等待它退出…,此时重启服务器也没有用,用命令杀死进程就可以了
    
    # rm -f /var/run/yum.pid
    
    
    
  3. 查看redis包全名

    全名是:php71w-pecl-redis.x86_64
    
  4. yum安装redis扩展

    # yum install php71w-pecl-redis.x86_64
    
  5. 重启php-fpm

    # service php-fpm restart
    
  6. 查看phpinfo信息

    有redis版块,说明安装成功!

    提示:添加PHP的其它扩展大致一样

你可能感兴趣的:(linux-centos)