安装
安装homebrew(mac的包管理器)
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
确认是否安装成功:brew -v
安装nginx
brew install nginx
确认是否安装成功:nginx -v
启动nginx(默认为8080端口)
brew services start(重启为restart) nginx
检查nginx是否启动成功,在浏览器输入:
localhost:8080(若成功,则显示nginx欢迎页面)
修改配置
查看配置
cat /usr/local/etc/nginx/nginx.conf
修改配置
vim /usr/local/etc/nginx/nginx.conf
配置demo
server {
listen 8080;
server_name localhost;
charset utf-8;
#access_log logs/host.access.log main;
## 项目路径配置为本地项目根目录
location / {
root /Users/haha/Documents/app;
index index.html index.htm;
}
## 代理
location /api/ {
proxy_pass http://172.32.2.6;
}
}