在/Library/LaunchDaemons下新建com.redis.plist
com.redis.plist内容如下:
<?xmlversion="1.0"encoding="UTF-8"?>
<!DOCTYPEplist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plistversion="1.0">
<dict>
<key>Label</key>
<string>com.redis</string>
<key>RunAtLoad</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/redis-server</string>
</array>
</dict>
</plist>
sudo launchctl load /Library/LaunchDaemons/com.redis.plist
如果提示:
/Library/LaunchDaemons/com.redis.plist: Path had bad ownership/permissions
那么就是说权限不够
可以采用执行下面的命令
sudo chown root /Library/LaunchDaemons/com.redis.plist
最后:
sudo launchctl start com.redis
重启电脑试试吧