通过homebrew安装nginx;
homebrew官网:https://brew.sh/index_zh-cn.html
1. 安装homebrew(已经有homebrew的跳过该步骤)
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
2.检查nginx是否已经安装过
brew search nginx
:查询要安装的软件是否存在
3.检查nginx相关信息
brew info nginx
4.安装nginx
brew install nginx
5.打开nginx目录
安装目录可以通过brew info nginx
查到,如: open /usr/local/etc/nginx/
打开nginx目录;
如:
![](https://img.haomeiwen.com/i7450593/67101e9effc46bf0.png)
/usr/local/Cellar/nginx/
其中有个html目录,该目录指向
/usr/local/var/www
![](https://img.haomeiwen.com/i7450593/a19b316e27d489b9.png)
/usr/local/etc/nginx/
![](https://img.haomeiwen.com/i7450593/fc3850b363f3bef6.png)
6.启动nginx,查看进程数
没有报错即为启动成功。
nginx
查看进程数
ps -eaf|grep nginx
7.检查是否启动成功
浏览器输入
http://localhost:8080/
![](https://img.haomeiwen.com/i7450593/0dff54b99d48a618.png)
8.启动、停止nginx
启动: nginx
停止: nginx -s stop
退出: nginx -s quit || sudo pkill -9 nginx
重启: nginx -s reload
nginx -s quit:此方式停止步骤是待nginx进程处理任务完毕进行停止。
nginx -s stop:此方式相当于先查出nginx进程id再使用kill命令强制杀掉进程。
查询nginx进程:
ps aux|grep nginx
网友评论