redis安装启动脚本
#!/bin/bash
# sudo yum install -y gcc
# sudo yum install -y ruby build-essential
BASE=/usr/local
ps aux | grep redis-server | awk '{print $2}' | xargs kill -9
REDIS_HOME=$BASE'/redis-3.2.0'
cd $BASE
sudo tar zxvf ./redis-3.2.0.tar.gz
cd $REDIS_HOME
sudo make
REDIS_FILE=$REDIS_HOME/redis.conf
sudo sed -i 's/bind 127.0.0.1/#bind 127.0.0.1/g' $REDIS_FILE;
sudo sed -i 's/pidfile \/var\/run\/redis.pid/pidfile \/var\/run\/redis_6379.pid/g' $REDIS_FILE;
sudo sed -i 's/daemonize no/daemonize yes/g' $REDIS_FILE;
sudo sed -i 's/appendonly no/appendonly yes/g' $REDIS_FILE;
sudo sed -i 's/# requirepass foobared/requirepass redis_qwe_123/g' $REDIS_FILE;
sudo make PREFIX=/usr/local/redis-3.2.0 install
sudo $REDIS_HOME/src/redis-server $REDIS_HOME/redis.conf;
echo 'Server started on port 6379';
将redis-cli redis-server拷贝到linux的bin目录中,这样就不用进入redis的bin目录了。可以像使用linux命令一样能直接使用了。
cp /usr/local/redis-3.2.0/bin/redis-cli /usr/local/bin/
cp /usr/local/redis-3.2.0/bin/redis-server /usr/local/bin/