whitek 发表于 2018-11-2 10:30:41

编译安装redis-f1221283的博客

  redis官网
  http://www.redis.cn/download.html
  1)安装详细步骤
  # wget http://download.redis.io/releases/redis-4.0.10.tar.gz
  # tar xzf redis-4.0.10.tar.gz

   make && make install
  Copy生成文件至指定目录
   cp src/redis-* /usr/local/bin/
  至此,redis已经安装完成。接下来是配置开机启动及将期添加至systemctl下进行管理
  2)新增redis用户及组
   groupadd redis
   useradd -c Redis Server -s /sbin/nologin
  3)增加服务
  vim /usr/lib/systemd/system/redis.service

  
Description=Redis persistent key-value database
  
After=network.target
  

  
ExecStart=/usr/local/bin/redis-server /etc/redis.conf --daemonize no
  
ExecStop=/usr/local/bin/redis-clishutdown
  
User=redis
  
Group=redis
  
RuntimeDirectory=redis
  
RuntimeDirectoryMode=0755
  

  
WantedBy=multi-user.target
  4)开机启动和 测试服务
   chkconfig --add redis
   systemctl enable redis.service
   systemctl status redis.service
   /usr/bin/redis-cli-h 127.0.0.1 -p 6379
  5)开启远程连接
  # vim /etc/redis.conf

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


页: [1]
查看完整版本: 编译安装redis-f1221283的博客