安装redis服务
1 下载redis
1 2 | cd /usr/local/ 进入安装目录 wget http: //download .redis.io /redis-stable . tar .gz |
2 解压安装
1 2 3 | tar xvzf redis-stable. tar .gz cd redis-stable make && make install |
3 配置redis
![](https://files.jb51.net/file_images/article/201811/2018110115562620.png)
1 2 | 拷贝配置文件到 /etc/redis/redis .conf cp redis.conf /etc/redis/6379redis .conf |
![](https://files.jb51.net/file_images/article/201811/2018110115562721.png)
1 2 3 4 5 6 7 8 9 10 | vim /etc/redis/redis .conf 修改文件 把 daemonize 这一项改成 yes 增加:pidfile /var/redis/run/redis_6379 .pid 增加:logfile /var/redis/log/redis_6379 .log 增加: dir /var/redis/6379 保存退出 最后运行redis: redis-server /etc/redis/redis .conf 查看端口【6379】 netstat –atln |
4 打开客户端
进入安装目录打开 cd redis-stable/src/redis-cli
![](https://files.jb51.net/file_images/article/201811/2018110115562722.png)
安装php-redis扩展
1 下载redis扩展
1 | php-redis下载地址 https: //github .com /phpredis/phpredis |
2 解压安装
1 2 3 4 5 | unzip phpredis-develop.zip cd phpredis-develop 生成configure配置文件: /usr/local/php/bin/phpize 编译安装: . /configure --with-php-config= /usr/local/php-7 .1 /bin/php-config make && make install |
3 编辑php.ini文件
1 | vim /usr/local/php/etc/php .ini |
在文件末尾加上: extension=redis.so
4 重启httpd
5 phpinfo 查看
![](https://files.jb51.net/file_images/article/201811/2018110115562723.png)