mac下修改nginx配置

13次阅读

共计 411 个字符,预计需要花费 2 分钟才能阅读完成。

主要命令:

  1. 查看 nginx 信息:brew info nginx
  2. 切换至 nginx 配置文件所在路径:cd /usr/local/etc/nginx
  3. 修改 nginx 配置文件:vim nginx.conf
  4. 查看 ng 配置是否正确:nginx -t
  5. 重启 ng:nginx -s reload

详细步骤如下:

1、通过查看 nginx 信息,查看配置文件所在路径

brew info nginx

2、切换至配置文件所在路径

cd /usr/local/etc/nginx 

3、修改配置文件,以修改目录为例

将默认目录修改为指定目录 /Users/lanyf/www

vim nginx.conf

找到

location / {
            root   html;
            index  index.html index.htm;
        }

修改为

location / {
            root   /Users/lanyf/www;
            index  index.html index.htm;
        }

4、查看修改后的配置是否正确

nginx -t

5、重启 ng

nginx -s reload

正文完
 0