ubuntu 安装redis
1. 下载安装:
cd /tmp
wget http://redis.googlecode.com/files/redis-2.2.4.tar.gz
tar -zxf redis-2.2.4.tar.gz
cd redis-2.2.4
make
sudo make install
ps:我在make 的时候遇见如下错误:
/tmp/redis-2.2.4/src/vm.c:446: undefined reference to `log'
collect2: ld returned 1 exit status
make[1]: *** [redis-server] Error 1
make[1]: Leaving directory `/tmp/redis-2.2.4/src'
make: *** [all] Error 2
collect2: ld returned 1 exit status
make[1]: *** [redis-server] Error 1
make[1]: Leaving directory `/tmp/redis-2.2.4/src'
make: *** [all] Error 2
google了一下解决方案如下:
To fix it, again, I modified the Makefile in /tmp/redis-2.2.4/src/Makefile
Line 114: becomes
$(CC) -o $(PRGNAME) $(CCOPT) $(DEBUG) $(OBJ) -lm
Line 114: becomes
$(CC) -o $(PRGNAME) $(CCOPT) $(DEBUG) $(OBJ) -lm
2. 配置init脚本:
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. 初始化用户和日志路径
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. 启动Redis:
sudo /etc/init.d/redis-server start
添加一个服务
#sudo update-rc.d 服务名 defaults 99
删除一个服务
#sudo update-rc.d 服务名 remove
临时重启一个服务
#/etc/init.d/服务名 restart
临时关闭一个服务
#/etc/init.d/服务名 stop
临时启动一个服务
#/etc/init.d/服务名 start