我只是把命令放到shell文件中了,方便安装,代码如下:
#!/bin/bash # shell的执行选项: # -n 只读取shell脚本,但不实际执行 # -x 进入跟踪方式,显示所执行的每一条命令 # -c "string" 从strings中读取命令 # 下载目录 downloadsDir=/root/Downloads # 安装目录 appDir=/usr/local/redis # 判断备份目录是否存在,不存时新建目录 [ ! -d $downloadsDir ] && mkdir -p $downloadsDir cd $downloadsDir # 下载、解压、编译 wget http://download.redis.io/redis-stable.tar.gz tar xvzf redis-stable.tar.gz cd redis-stable make && make test # 若提示需要tcl或更高版本 # yum install -y tcl # make完后,一般建议make test,我在make test时提示 You need tcl 8.5 or newer in order to run the Redis test # wget http://prdownloads.sourceforge.net/tcl/tcl8.6.0-src.tar.gz # 下载后,进入安装目录,进入unix,然后执行"./configure",然后make,然后make install # 复制执行文件 cp src/redis-server /usr/local/bin/ cp src/redis-cli /usr/local/bin/ # 创建目录 mkdir /etc/redis mkdir /var/redis mkdir /var/redis/log mkdir /var/redis/run mkdir /var/redis/port # 复制redis解压根目录中中的配置文件模板 cp redis.conf /etc/redis/redis.conf # 修改配置文件 echo "################################ ZHAOXIACE DEFINE ##############################" >> /etc/redis/redis.conf echo "daemonize yes" >> /etc/redis/redis.conf echo "pidfile /var/redis/run/redis.pid" >> /etc/redis/redis.conf echo "logfile /var/redis/log/redis.log" >> /etc/redis/redis.conf echo "dir /var/redis/port" >> /etc/redis/redis.conf # 运行redis redis-server /etc/redis/redis.conf