linux系统安装redis服务器与php redis扩展

一 安装redis服务
1更新yum源
CentOS/RHEL 7.x:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
如果是centos6,那么执行以下代码:
CentOS/RHEL 6.x:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
 
2 通过yum源直接安装redis
yum install -y memcached redis
 
3 检测是否安装好redis-cli和redis-server
[root@localhost bin]# whereis redis-cli
redis-cli: /usr/bin/redis-cli
[root@localhost bin]# whereis redis-server
redis-server: /usr/bin/redis-server
 
4 启动redis
加上`&`号使redis以后台程序方式运行
redis-server &
 
5 检测后台进程是否存在
ps -ef |grep redis
 
6 使用客户端来检测连接是否正常
redis-cli
127.0.0.1:6379> keys *
(empty list or set)
127.0.0.1:6379> set key "hello world"
OK
127.0.0.1:6379> get key
"hello world"
 
7 尝试通过远程客户端软件来连接redis服务器
修改redis.conf 找到 bind 127.0.0.1 注释掉,默认只允许本机访问
为了登陆安全,再找到 requirepass yourpassword(设置一个密码即可)
 
二 安装php redis扩展
1 下载上传安装包
上传phpredis-2.2.4.tar.gz到/usr/local/src目录
 
2 执行命令安装
cd /usr/local/src #进入软件包存放目录
tar zxvf phpredis-2.2.4.tar.gz #解压
cd phpredis-2.2.4 #进入安装目录
/usr/local/php/bin/phpize #用phpize生成configure配置文件
./configure --with-php-config=/usr/local/php/bin/php-config #配置
make #编译
make install #安装
3 查看是否安装
php -m
原文地址:https://www.cnblogs.com/houweijian/p/7788768.html