CentOS安装Redis、PHPredis扩展

@lianst  December 22, 2017

安装Redis

[root@qzdev9 conf]# yum -y install redis #安装redis
[root@qzdev9 conf]# systemctl start redis # 启动redis
[root@qzdev9 conf]# systemctl status redis # 查看redis运行状态
● redis.service - Redis persistent key-value database
   Loaded: loaded (/usr/lib/systemd/system/redis.service; disabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/redis.service.d
           └─limit.conf
   Active: active (running) since Fri 2017-12-22 13:29:33 CST; 1h 44min ago
 Main PID: 1264 (redis-server)
   CGroup: /system.slice/redis.service
           └─1264 /usr/bin/redis-server 127.0.0.1:6379

Dec 22 13:29:33 qzdev9 systemd[1]: Started Redis persistent key-value database.
Dec 22 13:29:33 qzdev9 systemd[1]: Starting Redis persistent key-value database...

安装phpredis

[root@qzdev9 software]# wget --no-check-certificate  https://dl.lianst.com/redis/phpredis/2.2.4.tar.gz # 下载phpredis
[root@qzdev9 software]# wget --no-check-certificate  https://github.com/nicolasff/phpredis/archive/master.zip # 备用地址
[root@qzdev9 software]# git clone https://github.com/phpredis/phpredis.git #php7使用这个版本
[root@qzdev9 software]# tar -zxvf 2.2.4.tar.gz 
[root@qzdev9 software]# cd phpredis-2.2.4/
[root@qzdev9 phpredis-2.2.4]# phpize
Configuring for:
PHP Api Version:         20100412
Zend Module Api No:      20100525
Zend Extension Api No:   220100525
[root@qzdev9 phpredis-2.2.4]# ./configure --with-php-config=/usr/local/php/bin/php-config
[root@qzdev9 phpredis-2.2.4]# make && make install 
....
Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/ # 这个路径是要添加php.ini文件最下方的。

配置PHP支持redis

[root@qzdev9 phpredis-2.2.4]# vim /usr/local/php/etc/php.ini # 编辑php.ini文件
....
# 在文件最下面新增如下两句
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525"
extension=redis.so
[root@qzdev9 phpredis-2.2.4]# /etc/init.d/php-fpm restart # 重载php-fpm
Gracefully shutting down php-fpm . done
Starting php-fpm  done


添加新评论

  1. 非常感谢,我在弄云服务器时,折腾了半天才弄好。

    Reply