<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          Nginx完全教程(必讀)

          作者: 時(shí)間:2016-10-08 來源:網(wǎng)絡(luò) 收藏

          --with-sha1-opt=OPTIONS - Set additional options for sha1 building.

          --with-sha1-asm - Use sha1 assembler sources.

          --with-zlib=DIR - Set path to zlib library sources.

          --with-zlib-opt=OPTIONS - Set additional options for zlib building.

          --with-zlib-asm=CPU - Use zlib assembler sources optimized for specified CPU, valid values are: pentium, pentiumpro

          --with-openssl=DIR - Set path to OpenSSL library sources

          --with-openssl-opt=OPTIONS - Set additional options for OpenSSL building

          --with-debug - 啟用調(diào)試日志

          --add-module=PATH - Add in a third-party module found in directory PATH

          在不同版本間,選項(xiàng)可能會(huì)有些許變化,請(qǐng)總是使用 ./configure --help 命令來檢查一下當(dāng)前的選項(xiàng)列表。

          示例 (最好能在同一行):

          ./configure --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_ssl_module --with-pcre=../pcre-4.4 --with-zlib=../zlib-1.1.3

          Ubuntu/debian 上的示例,需要預(yù)先安裝 libgcrypt11-dev, libpcre3-dev 和 libssl-dev (選擇 --with-md5 或 --with-sha1 中的一個(gè), 但不能都選; 在 debian 和 ubuntu 上, 它們應(yīng)該都指向 /usr/lib)

          ./configure --with-openssl=/usr/lib/ssl/ --with-md5=/usr/lib

          Ubuntu Edgy 的一個(gè) 0.5.2 版本的 .deb 包可以在這里下載: nginx_0.5.2-1_i386.deb.

          (注: 根據(jù) October 2006 message 的消息,md5 在一個(gè)現(xiàn)在不再使用的 http 緩存模塊中用到,而 sha1 用在一個(gè)未完成的 mysql 庫模塊,所以它們當(dāng)前都不是必須的)

          運(yùn)行和控制 Nginx - 命令行參數(shù)和信號(hào)

          不像許多其他軟件系統(tǒng),Nginx 僅有數(shù)個(gè)命令行參數(shù),完全通過配置文件來配置(想象一下)。

          · 選項(xiàng)

          · 示例

          · 使用信號(hào)加載新的配置

          · 平滑升級(jí)到新的二進(jìn)制代碼

          選項(xiàng)

          -c /path/to/config> 為 Nginx 指定一個(gè)配置文件,來代替缺省的。

          -t 不運(yùn)行,而僅僅測試配置文件。nginx 將檢查配置文件的語法的正確性,并嘗試打開配置文件中所引用到的文件。

          -v 顯示 nginx 的版本。

          -V 顯示 nginx 的版本,編譯器版本和配置參數(shù)。

          示例

          /usr/bin/nginx -t -c ~/mynginx.conf

          通過系統(tǒng)的信號(hào)控制 Nginx

          可以使用信號(hào)系統(tǒng)來控制主進(jìn)程。默認(rèn),nginx 將其主進(jìn)程的 pid 寫入到 /usr/local/nginx/logs/nginx.pid 文件中。通過傳遞參數(shù)給 ./configure 或使用 pid 指令,來改變?cè)撐募奈恢谩?p>主進(jìn)程可以處理以下的信號(hào):

          TERM, INT

          快速關(guān)閉

          QUIT

          從容關(guān)閉

          HUP

          重載配置

          用新的配置開始新的工作進(jìn)程

          從容關(guān)閉舊的工作進(jìn)程

          USR1

          重新打開日志文件

          USR2

          平滑升級(jí)可執(zhí)行程序。

          WINCH

          從容關(guān)閉工作進(jìn)程

          盡管你不必自己操作工作進(jìn)程,但是,它們也支持一些信號(hào):

          TERM, INT

          快速關(guān)閉

          QUIT

          從容關(guān)閉

          USR1

          重新打開日志文件

          使用信號(hào)加載新的配置

          Nginx 支持幾個(gè)信號(hào),能在它運(yùn)行時(shí)控制其操作。其中最普通的是 15 ,用來中止運(yùn)行的進(jìn)程:

          # ps aux | egrep '(PID|nginx)'USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMANDroot 2213 0.0 0.0 6784 2036 ? Ss 03:01 0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf

          # kill -15 2213

          而最有趣的是能平滑改變 nginx 配置的選項(xiàng)(請(qǐng)注意,在重載前,要先測試一下配置文件):

          # nginx -t -c /etc/nginx/nginx.conf2006/09/16 13:07:10 [info] 15686#0: the configuration file /etc/nginx/nginx.conf syntax is ok2006/09/16 13:07:10 [info] 15686#0: the configuration file /etc/nginx/nginx.conf was tested successfully

          # ps aux | egrep '(PID|nginx)'

          USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND

          root 2213 0.0 0.0 6784 2036 ? Ss 03:01 0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf

          # kill -HUP 2213

          當(dāng) nginx 接收到 HUP 信號(hào),它會(huì)嘗試先解析配置文件(如果指定配置文件,就使用指定的,否則使用默認(rèn)的),成功的話,就應(yīng)用新的配置文件(例如:重新打開日志文件或監(jiān)聽的套接 字)。之后,nginx 運(yùn)行新的工作進(jìn)程并從容關(guān)閉舊的工作進(jìn)程。通知工作進(jìn)程關(guān)閉監(jiān)聽套接字但是繼續(xù)為當(dāng)前連接的客戶提供服務(wù)。所有客戶端的服務(wù)完成后,舊的工作進(jìn)程被關(guān)閉。 如果新的配置文件應(yīng)用失敗,nginx 將繼續(xù)使用舊的配置進(jìn)行工作。

          平滑升級(jí)到新的二進(jìn)制代碼

          你可以在不中斷服務(wù)的情況下 - 新的請(qǐng)求也不會(huì)丟失,使用新的 nginx 可執(zhí)行程序替換舊的(當(dāng)升級(jí)新版本或添加/刪除服務(wù)器模塊時(shí))。

          首先,使用新的可執(zhí)行程序替換舊的(最好做好備份),然后,發(fā)送 USR2 (kill -USR2 pid)信號(hào)給主進(jìn)程。主進(jìn)程將重命名它的 .pid 文件為 .oldbin (比如:/usr/local/nginx/logs/nginx.pid.oldbin),然后執(zhí)行新的可執(zhí)行程序,依次啟動(dòng)新的主進(jìn)程和新的工作進(jìn)程:

          PID PPID USER %CPU VSZ WCHAN COMMAND33126 1 root 0.0 1164 pause nginx: master process /usr/local/nginx/sbin/nginx33134 33126 nobody 0.0 1368 kqread nginx: worker process (nginx)

          33135 33126 nobody 0.0 1380 kqread nginx: worker process (nginx)

          33136 33126 nobody 0.0 1368 kqread nginx: worker process (nginx)

          36264 33126 root 0.0 1148 pause nginx: master process /usr/local/nginx/sbin/nginx

          36265 36264 nobody 0.0 1364 kqread nginx: worker process (nginx)



          關(guān)鍵詞:

          評(píng)論


          相關(guān)推薦

          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();