yoo*_*uri 3 macos homebrew nginx
brew服务说nginx已经启动..
MacBook-Pro-van-Youri:Homebrew youri$ brew services start nginx
Service `nginx` already started, use `brew services restart nginx` to restart.
Run Code Online (Sandbox Code Playgroud)
与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
Run Code Online (Sandbox Code Playgroud)
我的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>/usr/local/opt/nginx/bin/nginx</string>
<string>-g</string>
<string>daemon off;</string>
</array>
<key>WorkingDirectory</key>
<string>/usr/local</string>
</dict>
</plist>
Run Code Online (Sandbox Code Playgroud)
酿酒服务清单说明如下:
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
Run Code Online (Sandbox Code Playgroud)
语法是oke:
MacBook-Pro-van-Youri:LaunchAgents youri$ plutil -lint homebrew.mxcl.nginx.plist
homebrew.mxcl.nginx.plist: OK
Run Code Online (Sandbox Code Playgroud)
当我运行时,sudo nginx
我可以访问我的网站
yoo*_*uri 13
因为nginx将从端口80开始,所以它必须是root.
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist
Run Code Online (Sandbox Code Playgroud)
移动homebrew.mxcl.nginx.plist
sudo mv ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
Run Code Online (Sandbox Code Playgroud)
从LaunchDaemons文件夹加载plist
sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
Run Code Online (Sandbox Code Playgroud)
现在,sudo brew services list
显示一个正在运行的nginx进程
Name Status User Plist
nginx started root /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
Run Code Online (Sandbox Code Playgroud)
在brew services list
没有root的情况下运行会导致错误状态,因为您需要root才能读取状态
归档时间: |
|
查看次数: |
3172 次 |
最近记录: |