问题描述:
Mac 重启后, 手动启动 nginx 太麻烦
解决:
加入开机自启动
(1)homebrew 安装 nginx 后, 安装目录下有一个 homebrew.mxcl.nginx.plist 文件, 在 Mac 系统上, .plist 文件就是服务开机启动的配置文件.
(2) 由于 nginx 监听 80 端口, 必须在开机启动的时候, 以管理员权限执行, 所以需要将此文件复制一份置于 / Library/LaunchDaemons 目录之下.
(3) 然后使用 launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.nginx.plist 加载 nginx 服务到系统启动服务中
代码:
- sudo cp /usr/local/opt/nginx/homebrew.mxcl.nginx.plist /Library/LaunchDaemons/
- sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
来源: http://www.jianshu.com/p/b20ff149cbcb