zoukankan      html  css  js  c++  java
  • Mac M1 Brew配置nginx开机自启动,解决nginx自启动不成功问题

    nginx需要root身份

    将启动文件拷贝进去

    sudo cp /opt/homebrew/Cellar/nginx/1.21.0/homebrew.mxcl.nginx.plist /Library/LaunchDaemons
    

    设置开启启动

    sudo lauchctl load -w /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
    

    我们可以看一下,里面的内容

    <?xml version="1.0" encoding="UTF-8"?>
    <!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>homebrew.mxcl.nginx</string>
        <key>RunAtLoad</key>
        <true/>
        <key>KeepAlive</key>
        <false/>
        <key>ProgramArguments</key>
        <array>
            <string>/opt/homebrew/opt/nginx/bin/nginx</string>
            <string>-g</string>
            <string>daemon off;</string>
        </array>
        <key>WorkingDirectory</key>
        <string>/opt/homebrew</string>
      </dict>
    </plist>
    

    此时并没有生效

     % sudo brew services list
    Name      Status  User   Plist
    mysql@5.7 unknown jiqing /Users/jiqing/Library/LaunchAgents/homebrew.mxcl.mysql@5.7.plist
    nginx     error   root   /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
    php@5.6   unknown jiqing /Users/jiqing/Library/LaunchAgents/homebrew.mxcl.php@5.6.plist
    php@7.4   stopped     
    

    重启之后

    % sudo brew services list
    Password:
    Name      Status  User   Plist
    mysql@5.7 unknown jiqing /Users/jiqing/Library/LaunchAgents/homebrew.mxcl.mysql@5.7.plist
    nginx     started root   /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
    php@5.6   unknown jiqing /Users/jiqing/Library/LaunchAgents/homebrew.mxcl.php@5.6.plist
    php@7.4   stopped    
    

    生效了。

    下次启动,停止记得带上sudo。

    % sudo brew services stop nginx
    % sudo brew services start nginx
    
    % brew services list
    Name      Status  User   Plist
    mysql@5.7 started jiqing /Users/jiqing/Library/LaunchAgents/homebrew.mxcl.mysql@5.7.plist
    nginx     unknown root   /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
    php@5.6   started jiqing /Users/jiqing/Library/LaunchAgents/homebrew.mxcl.php@5.6.plist
    php@7.4   stopped  
    

    不加sudo的两个服务。

  • 相关阅读:
    find命令之xargs
    find命令之exec
    find 命令概览
    mv命令
    locate 命令
    whereis 命令
    linux which 查看可执行文件的位置
    Linux应用总结:自动删除n天前日志
    Visual Studio
    Visual Studio- “无法启动此程序,因为计算机中丢失 xxx.dll尝试重新安装该程序以解决此问题"
  • 原文地址:https://www.cnblogs.com/jiqing9006/p/14857058.html
Copyright © 2011-2022 走看看