脚本
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32
echo "deb http://archive.ubuntu.com/ubuntu/ trusty main universe restricted multiverse" >> /etc/apt/sources.list
sudo apt-get update
sudo apt-get install sysv-rc-confsudo apt-get install -y gcc pkg-config build-essential if type -p redis-server; thenecho "redis has been installed."else#安装依赖yum install cpp binutils glibc-kernheaders glibc-common glibc-devel gcc make wget -y#解压并安装wget http://download.redis.io/releases/redis-7.0.5.tar.gztar zxvf redis-7.0.5.tar.gzrm -rf /usr/local/redis-7.0.5cp -r redis-7.0.5 /usr/local/cd /usr/local/redis-7.0.5 && make && make install#修改配置文件sed -i '309s/daemonize no/daemonize yes/' /usr/local/redis-7.0.5/redis.conf sed -i '87s/bind 127.0.0.1 -::1/#bind 127.0.0.1 -::1/' /usr/local/redis-7.0.5/redis.conf sed -i '111s/protected-mode yes/protected-mode no/' /usr/local/redis-7.0.5/redis.conf#设置密码sed -i '1036s/# requirepass foobared/requirepass Zenglg2012!@#/' /usr/local/redis-7.0.5/redis.conf#创建文件mkdir -p /etc/redischmod -R 777 /etc/redis#(在默认的配置文件路劲中放置配置文件)rm -rf /etc/redis/6379.conf cp -r /usr/local/redis-7.0.5/redis.conf /etc/redis/chmod -R 777 /etc/redis/redis.conf#修改文件名mv /etc/redis/redis.conf /etc/redis/6379.confrm -rf /etc/init.d/redisd#添加配置密码验证,解决无法关闭redis服务问题sed -i 17c'\$CLIEXEC -a "Zenglg2012!@#" -p \$REDISPORT shutdown' /usr/local/redis-7.0.5/utils/redis_init_scriptcp -r /usr/local/redis-7.0.5/utils/redis_init_script /etc/init.d/#修改文件名mv /etc/init.d/redis_init_script /etc/init.d/redisd#设置开机自启,linux下需要使用这个命令sudo update-rc.d redisd defaultsecho "Redis 部署完成!"firm -rf ./tmp.log
systemctl status redisd > ./tmp.log
if cat tmp.log |grep "running"
thenecho -e "\033[32m redisd服务已经启动! \033[0m"
elseecho -e "\033[31m redisd服务未安装! \033[0m"
fi
编译过程
出现下图说明安装成功
针对该服务器系统的说明
参考链接
https://www.cnblogs.com/juanxincai/p/16480501.html