1、在/ Library / LaunchDaemons目录下创建文件redis-server.plist
2、编辑redis-server.plist,输入一下内容
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>redis-server</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/redis-2.8.19/src/redis-server</string>
<string>/usr/local/redis-2.8.19/redis.conf</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
注意:/usr/local/redis-2.8.19/src/redis-server为redis安装路径,/usr/local/redis-2.8.19/redis.conf为redis的配置路径,请以自己的为准
3、将redis.server.plist加载到launchd中,命令:
sudo launchctl load /Library/LaunchDaemons/redis-server.plist
4、启动redis,命令:
udo launchctl start redis-server