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

<div id="content_views" class="markdown_views"> <!-- flowchart 箭頭圖標 勿刪 --> <svg xmlns="http://www.w3.org/2000/svg" style="display: none;"><path stroke-linecap="round" d="M5,0 0,2.5 5,5z" id="raphael-marker-block" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></path></svg> <p>nginx的配置放在<font color="#FF0000">nginx.conf</font>文件中,通常咱們能夠使用如下命令查看服務器中存在的nginx.conf文件。</p>php

<pre class="prettyprint" name="code"><code class="hljs r has-numbering">locate nginx.conf /usr/local/etc/nginx/nginx.conf /usr/local/etc/nginx/nginx.conf.default <span class="hljs-keyword">...</span></code></pre>linux

<p>若是服務器中存在多個nginx.conf文件,咱們並不知道實際上調用的是哪一個配置文件,所以咱們<strong><font color="#FF0000">必須找到實際調用的配置文件</font></strong>才能進行修改。 <br> <br></p>nginx

<h2 id="查看nginx實際調用的配置文件"><a name="t0"></a>查看nginx實際調用的配置文件</h2>web

<h3 id="1查看nginx路徑"><a name="t1"></a>1.查看nginx路徑</h3>服務器

<pre class="prettyprint" name="code"><code class="hljs livecodeserver has-numbering">ps aux|grep nginx root <span class="hljs-number">352</span> <span class="hljs-number">0.0</span> <span class="hljs-number">0.0</span> <span class="hljs-number">2468624</span> <span class="hljs-number">924</span> ?? S <span class="hljs-number">10</span>:<span class="hljs-number">43</span>上午 <span class="hljs-number">0</span>:<span class="hljs-number">00.08</span> nginx: worker <span class="hljs-built_in">process</span> root <span class="hljs-number">232</span> <span class="hljs-number">0.0</span> <span class="hljs-number">0.0</span> <span class="hljs-number">2459408</span> <span class="hljs-number">532</span> ?? S <span class="hljs-number">10</span>:<span class="hljs-number">43</span>上午 <span class="hljs-number">0</span>:<span class="hljs-number">00.02</span> nginx: master <span class="hljs-built_in">process</span> /usr/<span class="hljs-built_in">local</span>/opt/nginx/bin/nginx -g daemon off; root <span class="hljs-number">2345</span> <span class="hljs-number">0.0</span> <span class="hljs-number">0.0</span> <span class="hljs-number">2432772</span> <span class="hljs-number">640</span> s000 S+ <span class="hljs-number">1</span>:<span class="hljs-number">01</span>下午 <span class="hljs-number">0</span>:<span class="hljs-number">00.00</span> grep nginx</code></pre>markdown

<p>nginx的路徑爲:<font color="#FF0000">/usr/local/opt/nginx/bin/nginx</font> <br> <br></p>app

<h3 id="2查看nginx配置文件路徑"><a name="t2"></a>2.查看nginx配置文件路徑</h3>svg

<p>使用nginx的 <font color="#FF0000">-t</font> 參數進行配置檢查,便可知道實際調用的配置文件路徑及是否調用有效。</p>post

<pre class="prettyprint" name="code"><code class="hljs applescript has-numbering">/usr/<span class="hljs-keyword">local</span>/opt/nginx/bin/nginx -t nginx: <span class="hljs-keyword">the</span> configuration <span class="hljs-type">file</span> /usr/<span class="hljs-keyword">local</span>/etc/nginx/nginx.conf syntax <span class="hljs-keyword">is</span> ok nginx: configuration <span class="hljs-type">file</span> /usr/<span class="hljs-keyword">local</span>/etc/nginx/nginx.conf test <span class="hljs-keyword">is</span> successful</code></pre>測試

<p>測試可知,nginx的配置文件路徑爲:<font color="#FF0000">/usr/local/etc/nginx/nginx.conf</font> 且調用有效。</p> </div>

<div id="cnblogs_post_body" class="blogpost-body"><p>linux下如何查找nginx配置文件的位置,方法以下:</p> <p>先找出nginx可執行文件的路徑</p> <div class="cnblogs_Highlighter sh-gutter"> <div><div id="highlighter_557393" class="syntaxhighlighter php"><div class="toolbar"><span><a href="#" class="toolbar_item command_help help">?</a></span></div><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter"><div class="line number1 index0 alt2">1</div></td><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="php plain">ps -ef | grep nginx</code></div></div></td></tr></tbody></table></div></div> </div> <p>  </p> <p>返回<br>[root@localhost /data/nginx/logs 09:47:00&amp;&amp;23]#ps -ef | grep nginx <br>root 1734 1 0 Oct28 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf</p> <p>那麼/usr/local/nginx/conf/nginx.conf就是配置文件了</p></div>

相關文章
相關標籤/搜索