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);