---
title: "Redis配置和启动【转】"
author: "sitoto"
date: "2012-05-17T17:17:38Z"
tags: []
categories: ["Web前端"]
slug: "redis"
draft: false
lastmod: "2012-05-17T17:17:38Z"
id: 1533928
url: "https://sitoto.iteye.com/blog/1533928"
---

**启动redis时候提示：**

 

```
ARE YOU SURE YOU WANT TO USE VM?

Redis Virtual Memory is going to be deprecated soon,
we think you should NOT use it, but use Redis only if
your data is suitable for an in-memory database.
If you *really* want VM add this in the config file:

    really-use-vm yes
```

本机测试, 觉得没有必要，就注释掉了

```
#vm-enabled yes
```

From:  http://www.cnblogs.com/viaivi/archive/2011/12/08/2281319.html

================

### 1、下载安装

[?](http://www.cnblogs.com/viaivi/archive/2011/12/08/2281319.html)

`cd /tmp`

`wget http://redis.googlecode.com/files/redis-` `2` `.` `2` `.` `13` `.tar.gz`

`tar -zxf redis-` `2` `.` `2` `.` `13` `.tar.gz`

`cd redis-` `2` `.` `2` `.` `13`

`make`

`sudo make install`

这时Redis 的可执行文件被放到了/usr/local/bin

### 2、下载配置文件和init启动脚本：

[?](http://www.cnblogs.com/viaivi/archive/2011/12/08/2281319.html)

`wget https://github.com/ijonas/dotfiles/raw/master/etc/init.d/redis-server`

`wget https://github.com/ijonas/dotfiles/raw/master/etc/redis.conf`

`sudo mv redis-server /etc/init.d/redis-server`

`sudo chmod +x /etc/init.d/redis-server`

`sudo mv redis.conf /etc/redis.conf`

### 3、初始化用户和日志路径

第一次启动Redis前，建议为Redis单独建立一个用户，并新建data和日志文件夹

[?](http://www.cnblogs.com/viaivi/archive/2011/12/08/2281319.html)

`sudo useradd redis`

`sudo mkdir -p /var/lib/redis`

`sudo mkdir -p /var/log/redis`

`sudo chown redis.redis /var/lib/redis`

`sudo chown redis.redis /var/log/redis`

### 4、设置开机自动启动，关机自动关闭

[?](http://www.cnblogs.com/viaivi/archive/2011/12/08/2281319.html)

`sudo update-rc.d redis-server defaults`

### 5、启动Redis：

[?](http://www.cnblogs.com/viaivi/archive/2011/12/08/2281319.html)

`sudo /etc/init.d/redis-server start`

### 6、启动client客户端连接:

[?](http://www.cnblogs.com/viaivi/archive/2011/12/08/2281319.html)

`$ redis-cli`

`redis> set foo bar`

`OK`

`redis> get foo`

`"bar"`