军哥lnmp安装使用redis

 酷酷的超  Linux操作系统  2019-07-03  1676  发表评论

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
允许外网访问一定要做好相关安全措施!!!!!!!!!!

所有评论
加载评论 ...
发表评论