Mac安装Redis并后台运行
使用brew安装Redis
brew安装教程请参考链接:
点击此处快速安装brew
brew install redis
可能会安装失败报错(不报错直接跳过)
Error: The following directories are not writable by your user:
/usr/local/lib
You should change the ownership of these directories to your user.
sudo chown -R $(whoami) /usr/local/lib
And make sure that your user has write permission.
chmod u+w /usr/local/lib
出错修复,是因为没有权限导致,执行下两句:
sudo chown -R $(whoami) /usr/local/lib
或者
chmod u+w /usr/local/lib
安装成功
执行上述命令后出现以下,则成功安装:
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/redis-6.0.10
######################################################################## 100.0%
==> Pouring redis-6.0.10.mojave.bottle.tar.gz
==> Caveats
To have launchd start redis now and restart at login:
brew services start redis
Or, if you don't want/need a background service you can just run:
redis-server /usr/local/etc/redis.conf
==> Summary
/usr/local/Cellar/redis/6.0.10: 13 files, 3.7MB
Mac安装后路径
配置redis.conf
配置文件路径:/usr/local/etc/redis.conf
编辑配置文件
vim /usr/local/etc/redis.conf
# 找到 bind 将其注释
#bind 127.0.0.1
# 找到 protected-mode 值改为 no
protected-mode yes 改为 no
# 设置后台运行
daemonize no 改为 yes
保存使用命令"esc:wq 回车"(冒号不可省略)
启动redis
/usr/local/Cellar/redis/6.0.10/bin/redis-server /usr/local/etc/redis.conf &
查看redis进程,默认端口号:6379
ps -ef|grep redis
文章评论