请给我一段完整linux centos76版本的redis下载安装到部署修改对外的端口号为6009设置自动开机自动运行的全部完整步骤
以下是完整的Linux CentOS 7.6版本的Redis下载安装到部署修改对外的端口号为6009设置自动开机自动运行的步骤:
- 打开终端,使用以下命令下载Redis:
wget http://download.redis.io/releases/redis-5.0.8.tar.gz
- 解压Redis:
tar xzf redis-5.0.8.tar.gz
- 进入Redis目录:
cd redis-5.0.8
- 编译Redis:
make
- 安装Redis:
make install
- 复制Redis配置文件:
cp redis.conf /etc/redis.conf
- 修改Redis配置文件,将端口号改为6009:
vi /etc/redis.conf
找到以下行:
# bind 127.0.0.1
port 6379
将其改为:
# bind 127.0.0.1
port 6009
- 创建Redis启动脚本:
vi /etc/init.d/redis
在文件中输入以下内容:
#!/bin/sh
# chkconfig: 2345 95 05
# description: Redis Service
redis_server=/usr/local/bin/redis-server
redis_conf=/etc/redis.conf
case "$1" in
start)
echo "Starting Redis..."
$redis_server $redis_conf
;;
stop)
echo "Stopping Redis..."
pkill redis-server
;;
*)
echo "Usage: /etc/init.d/redis {start|stop}"
exit 1
esac
exit 0
- 修改Redis启动脚本的权限:
chmod 755 /etc/init.d/redis
- 添加Redis服务到系统服务列表:
chkconfig --add redis
- 设置Redis开机自动运行:
chkconfig redis on
- 启动Redis服务:
service redis start
现在,Redis已成功安装、部署并配置为使用6009端口的自动开机自动运行服务。
原文地址: https://www.cveoy.top/t/topic/ENF 著作权归作者所有。请勿转载和采集!