ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
- 1.下载redis [reids下载](http://www.redis.cn/download.html) - 2.解压 `tar -zxvf redis-4.0.9.tar.gz` ![](https://box.kancloud.cn/934143bba9267bbdc752e1073dded649_474x80.png) - 3.编译安装 `make && make install` ![](https://box.kancloud.cn/fe145b31e369b4e954afa62f07a36ce9_509x69.png) - 4.copy配置文件 `cp redis.conf /usr/local/etc/redis.conf ` - 5.查找redis服务并运行redis `whereis redis-server` 查找结果为 redis-server: /usr/local/bin/redis-server 运行: `/usr/local/bin/redis-server /usr/local/etc/redis.conf ` - 6.安装成功时候的样式 ![](https://box.kancloud.cn/19eed36159d4e5a627ba8b04e26d61ec_535x296.png) - 7.设置开机自启 a.查找和设置自己的redis路径参数 ~~~ #环境变量 PATH=/usr/local/bin:/sbin:/usr/bin:/bin #端口 REDISPORT=6379 #文件位置 EXEC=/usr/local/bin/redis-server REDIS_CLI=/usr/local/bin/redis-cli #PID位置 PIDFILE=/var/run/redis_6379.pid #位置文件位置位置 CONF="/usr/local/etc/redis.conf" ~~~ b.编写脚本 `vi /etc/init.d/redis` 复制下面代码到脚本中(注意要修改里面参数哦) ~~~ #!/bin/sh # chkconfig: - 85 15 # description: Start and Stop redis PATH=/usr/local/bin:/sbin:/usr/bin:/bin REDISPORT=6379 EXEC=/usr/local/bin/redis-server REDIS_CLI=/usr/local/bin/redis-cli PIDFILE=/var/run/redis_${REDISPORT}.pid CONF="/usr/local/etc/redis.conf" AUTH="1234" case "$1" in start) if [ -f $PIDFILE ] then echo "$PIDFILE exists, process is already running or crashed." else echo "Starting Redis server..." $EXEC $CONF fi if [ "$?"="0" ] then echo "Redis is running..." fi ;; stop) if [ ! -f $PIDFILE ] then echo "$PIDFILE exists, process is not running." else PID=$(cat $PIDFILE) echo "Stopping..." $REDIS_CLI -p $REDISPORT SHUTDOWN sleep 2 while [ -x $PIDFILE ] do echo "Waiting for Redis to shutdown..." sleep 1 done echo "Redis stopped" fi ;; restart|force-reload) ${0} stop ${0} start ;; *) echo "Usage: /etc/init.d/redis {start|stop|restart|force-reload}" >&2 exit 1 esac ~~~ * 提醒 vi 保存退出方法是 :wq c.保存退出,设置权限 `chmod 755 /etc/init.d/redis` - 7.启动redis `service redis start` - 8. 设置Redis开机启动 `chkconfig redis on` * 重启服务器 查看Redis服务是否启动 ~~~ reboot ps -ef | grep redis ~~~ ![](https://box.kancloud.cn/2e6fc623193591f51025ab0d261661c4_659x117.png) 为PHP安装redis扩展 - * 1.下载(php7可用) http://pecl.php.net/package/redis * 2.生成配置文件 切换到解压下的目录,然后运行命令: 对应你的php目录:`/usr/local/php7/bin/phpize` 然后一次运行 ~~~ ./configure --with-php-config=/usr/local/php7/bin/php-config  make  make install ~~~ 完成后显示: ![](https://box.kancloud.cn/ef5ef16dc2d1909571dfdc6ede9218af_747x223.png) 成功!!!