linux下如何查找nginx配置文件的位置

nginx的配置放在nginx.conf文件中,一般我们可以使用以下命令查看服务器中存在的nginx.conf文件。

<span style="background-color:rgba(0, 0, 0, 0)"><span style="color:#000000"><code>locate nginx.conf
/usr/local/etc/nginx/nginx.conf
/usr/local/etc/nginx/nginx.conf.default
<span style="color:#0000ff">...</span></code></span></span>

如果服务器中存在多个nginx.conf文件,我们并不知道实际上调用的是哪个配置文件,因此我们必须找到实际调用的配置文件才能进行修改。
 

查看nginx实际调用的配置文件

1.查看nginx路径

<span style="background-color:rgba(0, 0, 0, 0)"><span style="color:#000000"><code>ps aux|grep nginx
root              <span style="color:#880000">352</span>   <span style="color:#880000">0.0</span>  <span style="color:#880000">0.0</span>  <span style="color:#880000">2468624</span>    <span style="color:#880000">924</span>   ??  S    <span style="color:#880000">10</span>:<span style="color:#880000">43</span>上午   <span style="color:#880000">0</span>:<span style="color:#880000">00.08</span> nginx: worker <span style="color:#0000ff">process</span>  
root              <span style="color:#880000">232</span>   <span style="color:#880000">0.0</span>  <span style="color:#880000">0.0</span>  <span style="color:#880000">2459408</span>    <span style="color:#880000">532</span>   ??  S    <span style="color:#880000">10</span>:<span style="color:#880000">43</span>上午   <span style="color:#880000">0</span>:<span style="color:#880000">00.02</span> nginx: master <span style="color:#0000ff">process</span> /usr/<span style="color:#0000ff">local</span>/opt/nginx/bin/nginx -g daemon off;  
root             <span style="color:#880000">2345</span>   <span style="color:#880000">0.0</span>  <span style="color:#880000">0.0</span>  <span style="color:#880000">2432772</span>    <span style="color:#880000">640</span> s000  S+    <span style="color:#880000">1</span>:<span style="color:#880000">01</span>下午   <span style="color:#880000">0</span>:<span style="color:#880000">00.00</span> grep nginx</code></span></span>

nginx的路径为:/usr/local/opt/nginx/bin/nginx
 

2.查看nginx配置文件路径

使用nginx的 -t 参数进行配置检查,即可知道实际调用的配置文件路径及是否调用有效。

<span style="background-color:rgba(0, 0, 0, 0)"><span style="color:#000000"><code>/usr/<span style="color:#0000ff">local</span>/opt/nginx/bin/nginx -t
nginx: <span style="color:#0000ff">the</span> configuration <span style="color:#a31515">file</span> /usr/<span style="color:#0000ff">local</span>/etc/nginx/nginx.conf syntax <span style="color:#0000ff">is</span> ok
nginx: configuration <span style="color:#a31515">file</span> /usr/<span style="color:#0000ff">local</span>/etc/nginx/nginx.conf test <span style="color:#0000ff">is</span> successful</code></span></span>

测试可知,nginx的配置文件路径为:/usr/local/etc/nginx/nginx.conf 且调用有效。

linux下如何查找nginx配置文件的位置,方法如下:

先找出nginx可执行文件的路径

1
ps -ef | grep nginx

  

返回
[root@localhost /data/nginx/logs 09:47:00&&23]#ps -ef | grep nginx
root 1734 1 0 Oct28 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

那么/usr/local/nginx/conf/nginx.conf就是配置文件了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

七夜zippoe

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值