安装
1、打开终端
2、安装Command Line tools
xcode-select --install
3、安装brew命令
1ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
4、安装nginx
1brew install nginx
5、启动nginx
1sudo nginx
配置
要是8080端口被占用了,可以在配置文件中更改:
配置文件如下路径:
/usr/local/etc/nginx/nginx.conf
server {
listen 9090;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
在location中修改运行的网站的目录
location / {
root /Users/Documents/nginx/html;
index index.html index.htm;
}

访问
在127.0.0.1:9090中访问,要是遇到403错误如下解决:
user root owner即可解决

网友评论