Step1:安裝brew
En Taro Homebrew!
官網(wǎng)地址-https://brew.sh/
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Step2:使用brew安裝Nginx-full
推薦使用Nginx-full,自己想弄更多模塊可以在-full上輕松實(shí)現(xiàn)
brew tap denji/nginx
tap添加這個(gè)庫
brew install nginx-full
安裝nginx-full
Step3:配置Nginx
安裝默認(rèn)的配置文件在/usr/local/etc/nginx
其中的nginx.conf是總配置文件,我們最好不要去動(dòng)它,
vim nginx.conf讓它也加載server/文件夾中的配置文件(默認(rèn)應(yīng)該就是有的,可以check下)

nginx.conf中加字段
自己在
/usr/local/etc/nginx/server下新建一個(gè).conf文件,隨便取個(gè)名字~然后內(nèi)容為:
server {
listen 8080;# 端口號
charset utf-8,gbk;# 防中文亂碼
#設(shè)置站點(diǎn)域名
server_name 172.22.151.168;# 這個(gè)是你的域名,沒有的話直接鍵入內(nèi)網(wǎng)ip吧
#指向文件管理 文件夾
root /home/work/muban;# 自己指向一個(gè)想共享的文件夾吧
autoindex on;# 顯示目錄
autoindex_exact_size on;# 顯示文件大小
autoindex_localtime on;# 顯示文件時(shí)間
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
Step4:啟動(dòng)Nginx
brew services start nginx-full
然后去登錄你的地址就行啦
比如上面配置的則為172.22.151.168:8080

示例圖
關(guān)閉nginx使用
brew services stop nginx-full