nginx 的配置放在 nginx.conf 文件中, 一般我们可以使用以下命令查看服务器中存在的 nginx.conf 文件.
- locate nginx.conf
- /usr/local/etc/nginx/nginx.conf
- /usr/local/etc/nginx/nginx.conf.default
如果服务器中存在多个 nginx.conf 文件, 我们并不知道实际上调用的是哪个配置文件, 因此我们必须找到实际调用的配置文件才能进行修改.
查看 nginx 实际调用的配置文件
1. 查看 nginx 路径
ps aux|grep nginx
root 352 0.0 0.0 2468624 924 ?? S 10:43 上午 0:00.08 nginx: worker process
root 232 0.0 0.0 2459408 532 ?? S 10:43 上午 0:00.02 nginx: master process /usr/local/opt/nginx/bin/nginx -g daemon off;
root 2345 0.0 0.0 2432772 640 s000 S+ 1:01 下午 0:00.00 grep nginx
nginx 的路径为:
/usr/local/opt/nginx/bin/nginx
2. 查看 nginx 配置文件路径
使用 nginx 的 -t 参数进行配置检查, 即可知道实际调用的配置文件路径及是否调用有效.
- /usr/local/opt/nginx/bin/nginx -t
- nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
- nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
测试可知, nginx 的配置文件路径为:/usr/local/etc/nginx/nginx.conf 且调用有效.
来源: http://www.mzh.ren/b615e4db59fb.html