V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
coa
V2EX  ›  macOS

macOS 下 nginx 如何以 root 权限随机启动?

  •  
  •   coa · 2017-05-05 18:33:19 +08:00 · 2019 次点击
    这是一个创建于 2541 天前的主题,其中的信息可能已经有所发展或是发生改变。

    rt,使用 brew 安装的 nginx-full,用sudo brew services start设置了自启,也确认了自启项加到了/Library/LaunchDaemons,可每次电脑重启后还是访问不了 80 端口,8080 倒是正常。。非得手动sudo brew services restart一下才行。。。

    第 1 条附言  ·  2017-05-05 22:57:02 +08:00
    已解决。。
    貌似添加到 Launch Daemon 的自启项在开机时启动,此时未联网。。不加`sudo`添加到 Launch Agent,使其在用户登录时启动即可。。。
    5 条回复    2017-05-08 15:22:27 +08:00
    huijiewei
        1
    huijiewei  
       2017-05-05 19:34:01 +08:00 via iPhone
    launchrocket
    nan
        2
    nan  
       2017-05-05 20:05:27 +08:00 via iPhone
    使用 80 端口自启需要设置 bin/nginx 的权限和所有者,比如 chown root:wheel 和 chmod u+s
    lyf362345
        3
    lyf362345  
       2017-05-05 20:55:54 +08:00   ❤️ 1
    又是一个不认真看输出的
    brew info nginx-full

    - Tips -
    Run port 80:
    $ sudo chown root:wheel /usr/local/opt/nginx-full/bin/nginx
    $ sudo chmod u+s /usr/local/opt/nginx-full/bin/nginx
    Reload config:
    $ nginx -s reload
    Reopen Logfile:
    $ nginx -s reopen
    Stop process:
    $ nginx -s stop
    Waiting on exit process
    $ nginx -s quit

    To have launchd start homebrew/nginx/nginx-full now and restart at login:
    brew services start homebrew/nginx/nginx-full
    Or, if you don't want/need a background service you can just run:
    nginx
    coa
        4
    coa  
    OP
       2017-05-05 21:11:13 +08:00
    可能乌龙了。。设置的反向代理没跑起来,所以直接就挂了,可是正常进入系统后 restart 下服务又能行,猜测会不会和启动时的联网状态有关。。不知道有没有办法等确认能够正常联网后才启动 nginx ?
    正常的 80 端口可以访问了,感谢楼上各位。。。
    lucifer9
        5
    lucifer9  
       2017-05-08 15:22:27 +08:00
    就我一个理解错了 随机启动 的意思了么
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2595 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 04:53 · PVG 12:53 · LAX 21:53 · JFK 00:53
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.