macOS下开机自启动nginx

编程

    mac重启后,手动nginx" title="启动nginx">启动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



以上是 macOS下开机自启动nginx 的全部内容, 来源链接: utcz.com/z/515990.html

回到顶部