赞
踩
# brew安装nginx
# 安装nginx
# 可以用brew很方便地安装nginx.
sudo brew install nginx
# 启动nginx服务
sudo brew services start nginx
# 利用http://localhost:8080进行访问, 如果出现如下界面,说明启动成功.
### mac 自带的 apache是自启动的,而且是不允许删除 apache 的,所以我们只能采取以下办法解决:关闭apache随系统启动
> sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
### 开启apache随系统启动unload 改为 load 即可。
#Apache命令
停止服务:sudo /usr/sbin/apachectl stop
开启服务:sudo /usr/sbin/apachectl start
重启服务:sudo /usr/sbin/apachectl restart
#查看nginx版本
nginx -v
#关闭nginx服务
sudo brew services stop nginx
启动nginx:
sudo nginx
1
判断配置文件是否正确
sudo nginx -t
1
停止nginx:
sudo nginx -s stop
1
重启nginx:
sudo nginx -s reload
mac os x下nginx开机自启动
按照apple developer官网所说的,用户的开机自启动任务一般都需要在以下目录建立一个plist文件:
/Library/LaunchDaemons/
/Library/LaunchAgents/
~/Library/LaunchAgents/
这次我们在/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>nginx</string>
<key>Program</key>
<string>/usr/local/nginx/sbin/nginx</string>
<key>KeepAlive</key>
<true/>
<key>NetworkState</key>
<true/>
<key>LaunchOnlyOnce</key>
<true/>
</dict>
</plist>
然后加载:
sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
详细配置文件请看我的博客:https://blog.csdn.net/sunny243788557/article/details/106022683
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。