brew services says nginx is started..
MacBook-Pro-van-Youri:Homebrew youri$ brew services start nginx
Service `nginx` already started, use `brew services restart nginx` to restart.
字符串
launchctl也是如此
MacBook-Pro-van-Youri:Homebrew youri$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist
/Users/youri/Library/LaunchAgents/homebrew.mxcl.nginx.plist: service already loaded
型
我的自制软件.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>/usr/local/opt/nginx/bin/nginx</string>
<string>-g</string>
<string>daemon off;</string>
</array>
<key>WorkingDirectory</key>
<string>/usr/local</string>
</dict>
</plist>
型
brew services list说:
MacBook-Pro-van-Youri:LaunchAgents youri$ brew services list
Name Status User Plist
mariadb started youri /Users/youri/Library/LaunchAgents/homebrew.mxcl.mariadb.plist
nginx error youri /Users/youri/Library/LaunchAgents/homebrew.mxcl.nginx.plist
php71 started youri /Users/youri/Library/LaunchAgents/homebrew.mxcl.php71.plist
型
语法是oke:
MacBook-Pro-van-Youri:LaunchAgents youri$ plutil -lint homebrew.mxcl.nginx.plist
homebrew.mxcl.nginx.plist: OK
型
当我运行sudo nginx
时,我可以访问我的网站
2条答案
按热度按时间hfsqlsce1#
由于nginx将在端口80启动,因此它需要root。当用户登录时,LaunchAgent以非root用户身份运行。LaunchDaemons在 Boot 时以root用户身份加载。
字符串
移动
homebrew.mxcl.nginx.plist
型
从LaunchDaemons文件夹加载plist
型
现在,
sudo brew services list
显示了一个正在运行的nginx进程型
在没有root的情况下运行
brew services list
将导致错误状态,因为您需要root才能读取状态。zf9nrax12#
如上所述,发生这种情况是因为端口80是保留的,它需要由root分配。
更简单的方法是使用
sudo
运行brew services
字符串