首页 > 代码库 > ubuntu下安装redis
ubuntu下安装redis
(1)进去 /usr/local目录下
cd /usr/local
若没有local这个文件夹则创建一个
sudo mkdir /usr/local
sudo chmod 777 /usr/local
(2)下载redis
wget http://download.redis.io/releases/redis-2.8.12.tar.gz
解压
tar zxvf redis-2.8.12.tar.gz
重命名为:redis2.8
mv redis-2.8.12 redis2.8
(3)编译,
cd /usr/local/redis2.8
make
(4)查看编译是否成功
cd /usr/local/redis2.8/src
make test
若出现以下的提示错误,是因为没有装tcl,要装下tcl
You need tcl 8.5 or newer in order to run the Redis test
make: *** [test] Error 1
下载tcl放在/usr/local目录下进行安装
cd /usr/local
wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz
解压
tar zxvf tcl8.6.1-src.tar.gz
解压好后,编译
cd tcl8.6.1/unix
./configure
make
make install
安装好tcl后重新查看编译是否成功
cd /usr/local/redis2.8
cd src
make test
若查看结果如下,表示编译成功
\o/ All tests passed without errors!
Cleanup: may take some time... OK
(5)安装
cd /usr/local/redis2.8/src
make install
(6)redis命令默认目录: /usr/local/bin/
下载配置文件和启动脚本
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
建立一个用户redis,并新建data和日志文件夹
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
设置开机自动启动
sudo update-rc.d redis-server defaults
启动redis
sudo /etc/init.d/redis-server start