kavo

军哥lnmp安装使用redis

cd
cd lnmp1.5
#执行
./addons.sh install redis
#直接回车安装最新稳定版本

Build complete.
Don't forget to run 'make test'.

Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20151012/
Add to auto startup...
Add redis service at system startup...
Restarting php-fpm......
Gracefully shutting down php-fpm . done
Starting php-fpm  done
Starting Redis server...24003:C 26 Nov 07:52:19.875 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
24003:C 26 Nov 07:52:19.875 # Redis version=4.0.9, bits=64, commit=00000000, modified=0, pid=24003, just started
24003:C 26 Nov 07:52:19.875 # Configuration loaded
 done
====== Redis install completed ======
Redis installed successfully, enjoy it!

以上安装成功,并加入开机启动,因为一台服务器后续要用到,所以先安装一下redis

安装完成后,默认无密码,只允许本机访问:127.0.0.1 端口6379

如果你需要使用密码

vi /usr/local/redis/etc/redis.conf

#到500行左右,将requirepass注释去掉,后面修改为你想要的密码
    487 ################################## SECURITY ###################################
    488 
    489 # Require clients to issue AUTH <PASSWORD> before processing any other
    490 # commands.  This might be useful in environments in which you do not trust
    491 # others with access to the host running redis-server.
    492 #
    493 # This should stay commented out for backward compatibility and because most
    494 # people do not need auth (e.g. they run their own servers).
    495 #
    496 # Warning: since Redis is pretty fast an outside user can try up to
    497 # 150k passwords per second against a good box. This means that you should
    498 # use a very strong password otherwise it will be very easy to break.
    499 #
    500 # requirepass foobared

启动脚本就无法stop了,提示(error) NOAUTH Authentication required,因为redis自启动命令没有密码连接设置

     vi /etc/init.d/redis
    #搜索shudown
     42         if [ ! -f "$PIDFILE" ]; then
     43             echo "$PIDFILE does not exist, process is not running"
     44         else
     45             PID=$(cat $PIDFILE)
     46             echo "Stopping  Redis server..."
     47             $REDIS_CLI -p $REDISPORT -a password shutdown
     48             if [ "$?"="0" ]; then
     49                 echo " done"
     50             else
     51                 echo " failed"
     52             fi
     53         fi

#设置密码后必须有密码才能在cli下进行操作
#编辑  /etc/init.d/redis 查找shutdown在前面加上 -a 密码 ,-a前面和密码后面都有空格

如果需要外网访问:

除了要修改 /usr/local/redis/etc/redis.conf 里将bind 127.0.0.1 改成 bind 0.0.0.0 重启redis 
还需要将防火墙里redis的端口 6379的禁止访问规则去掉,参考iptables教程:https://www.vpser.net/security/linux-iptables.html
允许外网访问一定要做好相关安全措施!!!!!!!!!!

 

posted on   下雨天唱情歌  阅读(17)  评论(0编辑  收藏  举报  

编辑推荐:
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
阅读排行:
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示