redis官网php
http://www.redis.cn/download.html html
1)安装详细步骤redis
[root@liujihaoth ~]# wget http://download.redis.io/releases/redis-4.0.10.tar.gz vim
[root@liujihaoth soft]# tar xzf redis-4.0.10.tar.gz服务器
[root@liujihaoth redis-4.0.10] make && make install微信
Copy生成文件至指定目录ide
[root@liujihaoth redis-4.0.10] cp src/redis-* /usr/local/bin/测试
至此,redis已经安装完成。 接下来是配置开机启动及将期添加至systemctl下进行管理this
2)新增redis用户及组spa
[root@liujihaoth redis-4.0.10] groupadd redis
[root@liujihaoth redis-4.0.10] useradd -c Redis Server -s /sbin/nologin
3)增长服务
vim /usr/lib/systemd/system/redis.service
[Unit] Description=Redis persistent key-value database After=network.target [Service] ExecStart=/usr/local/bin/redis-server /etc/redis.conf --daemonize no ExecStop=/usr/local/bin/redis-cli shutdown User=redis Group=redis RuntimeDirectory=redis RuntimeDirectoryMode=0755 [Install] WantedBy=multi-user.target
4)开机启动和 测试服务
[root@liujihaoth redis-4.0.10] chkconfig --add redis
[root@liujihaoth redis-4.0.10] systemctl enable redis.service
[root@liujihaoth redis-4.0.10] systemctl status redis.service
[root@liujihaoth redis-4.0.10] /usr/bin/redis-cli -h 127.0.0.1 -p 6379
5)开启远程链接
[root@liujihaoth redis-4.0.10]# vim /etc/redis.conf
[root@liujihaoth redis-4.0.10] systemctl restart redis.service
6)PHP链接测试
$ip = "xx.xxx.xx";//改为本身的服务器地址 $port = 6379; $redis = new Redis(); $redis->pconnect($ip, $port, 1); $key = "test"; $value = "this is test"; $redis->set($key, $value); $d = $redis->get($key); var_dump($d);