當(dāng)前位置:首頁 > 嵌入式 > 嵌入式軟件
[導(dǎo)讀] Nginx完全教程(必讀)Nginx 概述HTTP基礎(chǔ)功能:· 處理靜態(tài)文件,索引文件以及自動索引;· 反向代理加速(無緩存),簡單的負(fù)載均衡和容錯(cuò);IXDBA.NET技術(shù)社區(qū)&mi

 Nginx完全教程(必讀)

Nginx 概述

HTTP基礎(chǔ)功能:

· 處理靜態(tài)文件,索引文件以及自動索引;

· 反向代理加速(無緩存),簡單的負(fù)載均衡和容錯(cuò);

IXDBA.NET技術(shù)社區(qū)

· FastCGI,簡單的負(fù)載均衡和容錯(cuò);

· 模塊化的結(jié)構(gòu)。過濾器包括gzipping, byte ranges, chunked responses, 以及 SSI-filter 。在SSI過濾器中,到同一個(gè) proxy 或者 FastCGI 的多個(gè)子請求并發(fā)處理;

· SSL 和 TLS SNI 支持;

IMAP/POP3 代理服務(wù)功能:

· 使用外部 HTTP 認(rèn)證服務(wù)器重定向用戶到 IMAP/POP3 后端;

· 使用外部 HTTP 認(rèn)證服務(wù)器認(rèn)證用戶后連接重定向到內(nèi)部的 SMTP 后端;

· 認(rèn)證方法:

o POP3: POP3 USER/PASS, APOP, AUTH LOGIN PLAIN CRAM-MD5;

o IMAP: IMAP LOGIN;

o SMTP: AUTH LOGIN PLAIN CRAM-MD5;

· SSL 支持;

· 在 IMAP 和 POP3 模式下的 STARTTLS 和 STLS 支持;

支持的操作系統(tǒng):

· FreeBSD 3.x, 4.x, 5.x, 6.x i386; FreeBSD 5.x, 6.x amd64;

· Linux 2.2, 2.4, 2.6 i386; Linux 2.6 amd64;

· Solaris 8 i386; Solaris 9 i386 and sun4u; Solaris 10 i386;

· MacOS X (10.4) PPC;

結(jié)構(gòu)與擴(kuò)展:

· 一個(gè)主進(jìn)程和多個(gè)工作進(jìn)程。工作進(jìn)程是單線程的,且不需要特殊授權(quán)即可運(yùn)行;

· kqueue (FreeBSD 4.1+), epoll (Linux 2.6+), rt signals (Linux 2.2.19+), /dev/poll (Solaris 7 11/99+), select, 以及 poll 支持;

· kqueue支持的不同功能包括 EV_CLEAR, EV_DISABLE (臨時(shí)禁止事件), NOTE_LOWAT, EV_EOF, 有效數(shù)據(jù)的數(shù)目,錯(cuò)誤代碼;

· sendfile (FreeBSD 3.1+), sendfile (Linux 2.2+), sendfile64 (Linux 2.4.21+), 和 sendfilev (Solaris 8 7/01+) 支持;

· 輸入過濾 (FreeBSD 4.1+) 以及 TCP_DEFER_ACCEPT (Linux 2.4+) 支持;

· 10,000 非活動的 HTTP keep-alive 連接僅需要 2.5M 內(nèi)存。

· 最小化的數(shù)據(jù)拷貝操作;

其他HTTP功能:

· 基于IP 和名稱的虛擬主機(jī)服務(wù);

· Memcached 的 GET 接口;

· 支持 keep-alive 和管道連接;

· 靈活簡單的配置;

· 重新配置和在線升級而無須中斷客戶的工作進(jìn)程;

· 可定制的訪問日志,日志寫入緩存,以及快捷的日志回卷;

· 4xx-5xx 錯(cuò)誤代碼重定向;

· 基于 PCRE 的 rewrite 重寫模塊;

· 基于客戶端 IP 地址和 HTTP 基本認(rèn)證的訪問控制;

· PUT, DELETE, 和 MKCOL 方法;

· 支持 FLV (Flash 視頻);

· 帶寬限制;

實(shí)驗(yàn)特性:

· 內(nèi)嵌的 perl

· 通過 aio_read()/aio_write() 的套接字工作的實(shí)驗(yàn)?zāi)K,僅在 FreeBSD 下。

· 對線程的實(shí)驗(yàn)化支持,F(xiàn)reeBSD 4.x 的實(shí)現(xiàn)基于 rfork()

為什么選擇Nginx

Nginx 是一個(gè)高性能的 Web 和反向代理服務(wù)器, 它具有有很多非常優(yōu)越的特性:

· 作為 Web 服務(wù)器:相比 Apache,Nginx 使用更少的資源,支持更多的并發(fā)連接,體現(xiàn)更高的效率,這點(diǎn)使 Nginx 尤其受到虛擬主機(jī)提供商的歡迎。能夠支持高達(dá) 50,000 個(gè)并發(fā)連接數(shù)的響應(yīng),感謝 Nginx 為我們選擇了 epoll and kqueue 作為開發(fā)模型.

· 作為負(fù)載均衡服務(wù)器:Nginx 既可以在內(nèi)部直接支持 Rails 和 PHP,也可以支持作為 HTTP代理服務(wù)器 對外進(jìn)行服務(wù)。Nginx 用 C 編寫, 不論是系統(tǒng)資源開銷還是 CPU 使用效率都比 Perlbal 要好的多。

· 作為郵件代理服務(wù)器: Nginx 同時(shí)也是一個(gè)非常優(yōu)秀的郵件代理服務(wù)器(最早開發(fā)這個(gè)產(chǎn)品的目的之一也是作為郵件代理服務(wù)器),Last.fm 描述了成功并且美妙的使用經(jīng)驗(yàn)。

· Nginx 安裝非常的簡單,配置文件 非常簡潔(還能夠支持perl語法),Bugs非常少的服務(wù)器: Nginx 啟動特別容易,并且?guī)缀蹩梢宰龅?*24不間斷運(yùn)行,即使運(yùn)行數(shù)個(gè)月也不需要重新啟動。你還能夠在 不間斷服務(wù)的情況下進(jìn)行軟件版本的升級。

安裝Nginx

預(yù)先編譯好的安裝包

Nginx在一些Linux發(fā)行版和BSD的各個(gè)變種版本的安裝包倉庫中都會有,通過各個(gè)系統(tǒng)自帶的軟件包管理方法即可安裝。需要注意的是,很多預(yù)先編譯好的安裝包都比較陳舊,大多數(shù)情況下還是推薦直接從源碼編譯。

官方源代碼下載

點(diǎn)擊下載源代碼

使用源代碼進(jìn)行構(gòu)建

Nginx 使用 Unix 下常用的 './configure && make && make install' 過程來編譯安裝。

configure 腳本確定系統(tǒng)所具有一些特性,特別是 nginx 用來處理連接的方法。然后,它創(chuàng)建 Makefile 文件。

configure 支持下面的選項(xiàng):

--prefix=<path> - Nginx安裝路徑。如果沒有指定,默認(rèn)為 /usr/local/nginx。

--sbin-path=<path> - Nginx可執(zhí)行文件安裝路徑。只能安裝時(shí)指定,如果沒有指定,默認(rèn)為<prefix>/sbin/nginx。

--conf-path=<path> - 在沒有給定-c選項(xiàng)下默認(rèn)的nginx.conf的路徑。如果沒有指定,默認(rèn)為<prefix>/conf/nginx.conf。

--pid-path=<path> - 在nginx.conf中沒有指定pid指令的情況下,默認(rèn)的nginx.pid的路徑。如果沒有指定,默認(rèn)為 <prefix>/logs/nginx.pid。

--lock-path=<path> - nginx.lock文件的路徑。

--error-log-path=<path> - 在nginx.conf中沒有指定error_log指令的情況下,默認(rèn)的錯(cuò)誤日志的路徑。如果沒有指定,默認(rèn)為 <prefix>/logs/error.log。

--http-log-path=<path> - 在nginx.conf中沒有指定access_log指令的情況下,默認(rèn)的訪問日志的路徑。如果沒有指定,默認(rèn)為 <prefix>/logs/access.log。[!--empirenews.page--]

--user=<user> - 在nginx.conf中沒有指定user指令的情況下,默認(rèn)的nginx使用的用戶。如果沒有指定,默認(rèn)為 nobody。

--group=<group> - 在nginx.conf中沒有指定user指令的情況下,默認(rèn)的nginx使用的組。如果沒有指定,默認(rèn)為 nobody。

--builddir=DIR - 指定編譯的目錄

--with-rtsig_module - 啟用 rtsig 模塊

--with-select_module --without-select_module - Whether or not to enable the select module. This module is enabled by default if a more suitable method such as kqueue, epoll, rtsig or /dev/poll is not discovered by configure.

//允許或不允許開啟SELECT模式,如果 configure 沒有找到更合適的模式,比如:kqueue(sun os),epoll (linux kenel 2.6+), rtsig(實(shí)時(shí)信號)或者/dev/poll(一種類似select的模式,底層實(shí)現(xiàn)與SELECT基本相 同,都是采用輪訓(xùn)方法) SELECT模式將是默認(rèn)安裝模式

--with-poll_module --without-poll_module - Whether or not to enable the poll module. This module is enabled by default if a more suitable method such as kqueue, epoll, rtsig or /dev/poll is not discovered by configure.

--with-http_ssl_module - Enable ngx_http_ssl_module. Enables SSL support and the ability to handle HTTPS requests. Requires OpenSSL. On Debian, this is libssl-dev.

//開啟HTTP SSL模塊,使NGINX可以支持HTTPS請求。這個(gè)模塊需要已經(jīng)安裝了OPENSSL,在DEBIAN上是libssl

--with-http_realip_module - 啟用 ngx_http_realip_module

--with-http_addition_module - 啟用 ngx_http_addition_module

--with-http_sub_module - 啟用 ngx_http_sub_module

--with-http_dav_module - 啟用 ngx_http_dav_module

--with-http_flv_module - 啟用 ngx_http_flv_module

--with-http_stub_status_module - 啟用 "server status" 頁

--without-http_charset_module - 禁用 ngx_http_charset_module

--without-http_gzip_module - 禁用 ngx_http_gzip_module. 如果啟用,需要 zlib 。

--without-http_ssi_module - 禁用 ngx_http_ssi_module

--without-http_userid_module - 禁用 ngx_http_userid_module

--without-http_access_module - 禁用 ngx_http_access_module

--without-http_auth_basic_module - 禁用 ngx_http_auth_basic_module

--without-http_autoindex_module - 禁用 ngx_http_autoindex_module

--without-http_geo_module - 禁用 ngx_http_geo_module

--without-http_map_module - 禁用 ngx_http_map_module

--without-http_referer_module - 禁用 ngx_http_referer_module

--without-http_rewrite_module - 禁用 ngx_http_rewrite_module. 如果啟用需要 PCRE 。

--without-http_proxy_module - 禁用 ngx_http_proxy_module

--without-http_fastcgi_module - 禁用 ngx_http_fastcgi_module

--without-http_memcached_module - 禁用 ngx_http_memcached_module

--without-http_limit_zone_module - 禁用 ngx_http_limit_zone_module

--without-http_empty_gif_module - 禁用 ngx_http_empty_gif_module

--without-http_browser_module - 禁用 ngx_http_browser_module

--without-http_upstream_ip_hash_module - 禁用 ngx_http_upstream_ip_hash_module

--with-http_perl_module - 啟用 ngx_http_perl_module

--with-perl_modules_path=PATH - 指定 perl 模塊的路徑

--with-perl=PATH - 指定 perl 執(zhí)行文件的路徑

--http-log-path=PATH - Set path to the http access log

--http-client-body-temp-path=PATH - Set path to the http client request body temporary files

--http-proxy-temp-path=PATH - Set path to the http proxy temporary files

--http-fastcgi-temp-path=PATH - Set path to the http fastcgi temporary files

--without-http - 禁用 HTTP server

--with-mail - 啟用 IMAP4/POP3/SMTP 代理模塊

--with-mail_ssl_module - 啟用 ngx_mail_ssl_module

--with-cc=PATH - 指定 C 編譯器的路徑

--with-cpp=PATH - 指定 C 預(yù)處理器的路徑

--with-cc-opt=OPTIONS - Additional parameters which will be added to the variable CFLAGS. With the use of the system library PCRE in FreeBSD, it is necessary to indicate --with-cc-opt="-I /usr/local/include". If we are using select() and it is necessary to increase the number of file descriptors, then this also can be assigned here: --with-cc-opt="-D FD_SETSIZE=2048".

--with-ld-opt=OPTIONS - Additional parameters passed to the linker. With the use of the system library PCRE in FreeBSD, it is necessary to indicate --with-ld-opt="-L /usr/local/lib".

--with-cpu-opt=CPU - 為特定的 CPU 編譯,有效的值包括:pentium, pentiumpro, pentium3, pentium4, athlon, opteron, amd64, sparc32, sparc64, ppc64

--without-pcre - 禁止 PCRE 庫的使用。同時(shí)也會禁止 HTTP rewrite 模塊。在 "location" 配置指令中的正則表達(dá)式也需要 PCRE 。

--with-pcre=DIR - 指定 PCRE 庫的源代碼的路徑。

--with-pcre-opt=OPTIONS - Set additional options for PCRE building.

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

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

--with-md5-asm - Use md5 assembler sources.

--with-sha1=DIR - Set path to sha1 library sources.[!--empirenews.page--]

--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)可能會有些許變化,請總是使用 ./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ù)和信號

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

· 選項(xiàng)

· 示例

· 使用信號加載新的配置

· 平滑升級到新的二進(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)的信號控制 Nginx

可以使用信號系統(tǒng)來控制主進(jìn)程。默認(rèn),nginx 將其主進(jìn)程的 pid 寫入到 /usr/local/nginx/logs/nginx.pid 文件中。通過傳遞參數(shù)給 ./configure 或使用 pid 指令,來改變該文件的位置。

主進(jìn)程可以處理以下的信號:

TERM, INT

快速關(guān)閉

QUIT

從容關(guān)閉

HUP

重載配置

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

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

USR1

重新打開日志文件

USR2

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

WINCH

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

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

TERM, INT

快速關(guān)閉

QUIT

從容關(guān)閉

USR1

重新打開日志文件

使用信號加載新的配置

Nginx 支持幾個(gè)信號,能在它運(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)(請注意,在重載前,要先測試一下配置文件):

# 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 信號,它會嘗試先解析配置文件(如果指定配置文件,就使用指定的,否則使用默認(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ìn)制代碼

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

首先,使用新的可執(zhí)行程序替換舊的(最好做好備份),然后,發(fā)送 USR2 (kill -USR2 pid)信號給主進(jìn)程。主進(jìn)程將重命名它的 .pid 文件為 .oldbin (比如:/usr/local/nginx/logs/nginx.pid.oldbin),然后執(zhí)行新的可執(zhí)行程序,依次啟動新的主進(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)[!--empirenews.page--]

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

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

在這時(shí),兩個(gè) nginx 實(shí)例會同時(shí)運(yùn)行,一起處理輸入的請求。要逐步停止舊的實(shí)例,你必須發(fā)送 WINCH 信號給舊的主進(jìn)程,然后,它的工作進(jìn)程就將開始從容關(guān)閉:

PID PPID USER %CPU VSZ WCHAN COMMAND33126 1 root 0.0 1164 pause nginx: master process /usr/local/nginx/sbin/nginx33135 33126 nobody 0.0 1380 kqread nginx: worker process is shutting down (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)

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

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

一段時(shí)間后,舊的工作進(jìn)程處理了所有已連接的請求后退出,就僅由新的工作進(jìn)程來處理輸入的請求了:

PID PPID USER %CPU VSZ WCHAN COMMAND33126 1 root 0.0 1164 pause nginx: master process /usr/local/nginx/sbin/nginx36264 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)

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

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

這時(shí),因?yàn)榕f的服務(wù)器還尚未關(guān)閉它監(jiān)聽的套接字,所以,通過下面的幾步,你仍可以恢復(fù)舊的服務(wù)器:

· 發(fā)送 HUP 信號給舊的主進(jìn)程 - 它將在不重載配置文件的情況下啟動它的工作進(jìn)程

· 發(fā)送 QUIT 信號給新的主進(jìn)程,要求其從容關(guān)閉其工作進(jìn)程

· 發(fā)送 TERM 信號給新的主進(jìn)程,迫使其退出

· 如果因?yàn)槟承┰蛐碌墓ぷ鬟M(jìn)程不能退出,向其發(fā)送 KILL 信號

新的主進(jìn)程退出后,舊的主進(jìn)程會由移除 .oldbin 前綴,恢復(fù)為它的 .pid 文件,這樣,一切就都恢復(fù)到升級之前了。

如果嘗試升級成功,而你也希望保留新的服務(wù)器時(shí),發(fā)送 QUIT 信號給舊的主進(jìn)程使其退出而只留下新的服務(wù)器運(yùn)行:

PID PPID USER %CPU VSZ WCHAN COMMAND 36264 1 root 0.0 1148 pause nginx: master process /usr/local/nginx/sbin/nginx 36265 36264 nobody 0.0 1364 kqread nginx: worker process (nginx)

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

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

Nginx 配置優(yōu)化

hash表

Ngnix使用hash表來協(xié)助完成請求的快速處理。

考慮到保存鍵及其值的hash表存儲單元的大小不至于超出設(shè)定參數(shù)(hash bucket size), 在啟動和每次重新配置時(shí),Nginx為hash表選擇盡可能小的尺寸。

直到hash表超過參數(shù)(hash max size)的大小才重新進(jìn)行選擇. 對于大多數(shù)hash表都有指令來修改這些參數(shù)。例如,保存服務(wù)器名字的hash表是由指令 server_names_hash_max_size 和 server_names_hash_bucket_size所 控制的。參數(shù)hash bucket size總是等于hash表的大小,并且是一路處理器緩存大小的倍數(shù)。在減少了在內(nèi)存中的存取次數(shù)后,使在處理器中加速查找hash表鍵值成為可能。如果 hash bucket size等于一路處理器緩存的大小,那么在查找鍵的時(shí)候,最壞的情況下在內(nèi)存中查找的次數(shù)為2。第一次是確定存儲單元的地址,第二次是在存儲單元中查找鍵 值。因此,如果Nginx給出需要增大 hash max size 或 hash bucket size的提示,那么首要的是增大前一個(gè)參數(shù)的大小.

事件模型

Nginx支持如下處理連接的方法(I/O復(fù)用方法),這些方法可以通過use指令指定。

· select - 標(biāo)準(zhǔn)方法。 如果當(dāng)前平臺沒有更有效的方法,它是編譯時(shí)默認(rèn)的方法。你可以使用配置參數(shù) --with-select_module 和 --without-select_module 來啟用或禁用這個(gè)模塊。

· poll - 標(biāo)準(zhǔn)方法。 如果當(dāng)前平臺沒有更有效的方法,它是編譯時(shí)默認(rèn)的方法。你可以使用配置參數(shù) --with-poll_module 和 --without-poll_module 來啟用或禁用這個(gè)模塊。

· kqueue - 高效的方法,使用于 FreeBSD 4.1+, OpenBSD 2.9+, NetBSD 2.0 和 MacOS X. 使用雙處理器的MacOS X系統(tǒng)使用kqueue可能會造成內(nèi)核崩潰。

· epoll - 高效的方法,使用于Linux內(nèi)核2.6版本及以后的系統(tǒng)。在某些發(fā)行版本中,如SuSE 8.2, 有讓2.4版本的內(nèi)核支持epoll的補(bǔ)丁。

· rtsig - 可執(zhí)行的實(shí)時(shí)信號,使用于Linux內(nèi)核版本2.2.19以后的系統(tǒng)。默認(rèn)情況下整個(gè)系統(tǒng)中不能出現(xiàn)大于1024個(gè)POSIX實(shí)時(shí)(排隊(duì))信號。這種情況對于高負(fù)載的服務(wù)器來說是低效的;所以有必要通過調(diào)節(jié)內(nèi)核參數(shù) /proc/sys/kernel/rtsig-max 來增加隊(duì)列的大小??墒菑腖inux內(nèi)核版本2.6.6-mm2開始, 這個(gè)參數(shù)就不再使用了,并且對于每個(gè)進(jìn)程有一個(gè)獨(dú)立的信號隊(duì)列,這個(gè)隊(duì)列的大小可以用 RLIMIT_SIGPENDING 參數(shù)調(diào)節(jié)。當(dāng)這個(gè)隊(duì)列過于擁塞,nginx就放棄它并且開始使用 poll 方法來處理連接直到恢復(fù)正常。

· /dev/poll - 高效的方法,使用于 Solaris 7 11/99+, HP/UX 11.22+ (eventport), IRIX 6.5.15+ 和 Tru64 UNIX 5.1A+.

· eventport - 高效的方法,使用于 Solaris 10. 為了防止出現(xiàn)內(nèi)核崩潰的問題, 有必要安裝 這個(gè) 安全補(bǔ)丁。

本站聲明: 本文章由作者或相關(guān)機(jī)構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點(diǎn),本站亦不保證或承諾內(nèi)容真實(shí)性等。需要轉(zhuǎn)載請聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請及時(shí)聯(lián)系本站刪除。
換一批
延伸閱讀

9月2日消息,不造車的華為或?qū)⒋呱龈蟮莫?dú)角獸公司,隨著阿維塔和賽力斯的入局,華為引望愈發(fā)顯得引人矚目。

關(guān)鍵字: 阿維塔 塞力斯 華為

加利福尼亞州圣克拉拉縣2024年8月30日 /美通社/ -- 數(shù)字化轉(zhuǎn)型技術(shù)解決方案公司Trianz今天宣布,該公司與Amazon Web Services (AWS)簽訂了...

關(guān)鍵字: AWS AN BSP 數(shù)字化

倫敦2024年8月29日 /美通社/ -- 英國汽車技術(shù)公司SODA.Auto推出其旗艦產(chǎn)品SODA V,這是全球首款涵蓋汽車工程師從創(chuàng)意到認(rèn)證的所有需求的工具,可用于創(chuàng)建軟件定義汽車。 SODA V工具的開發(fā)耗時(shí)1.5...

關(guān)鍵字: 汽車 人工智能 智能驅(qū)動 BSP

北京2024年8月28日 /美通社/ -- 越來越多用戶希望企業(yè)業(yè)務(wù)能7×24不間斷運(yùn)行,同時(shí)企業(yè)卻面臨越來越多業(yè)務(wù)中斷的風(fēng)險(xiǎn),如企業(yè)系統(tǒng)復(fù)雜性的增加,頻繁的功能更新和發(fā)布等。如何確保業(yè)務(wù)連續(xù)性,提升韌性,成...

關(guān)鍵字: 亞馬遜 解密 控制平面 BSP

8月30日消息,據(jù)媒體報(bào)道,騰訊和網(wǎng)易近期正在縮減他們對日本游戲市場的投資。

關(guān)鍵字: 騰訊 編碼器 CPU

8月28日消息,今天上午,2024中國國際大數(shù)據(jù)產(chǎn)業(yè)博覽會開幕式在貴陽舉行,華為董事、質(zhì)量流程IT總裁陶景文發(fā)表了演講。

關(guān)鍵字: 華為 12nm EDA 半導(dǎo)體

8月28日消息,在2024中國國際大數(shù)據(jù)產(chǎn)業(yè)博覽會上,華為常務(wù)董事、華為云CEO張平安發(fā)表演講稱,數(shù)字世界的話語權(quán)最終是由生態(tài)的繁榮決定的。

關(guān)鍵字: 華為 12nm 手機(jī) 衛(wèi)星通信

要點(diǎn): 有效應(yīng)對環(huán)境變化,經(jīng)營業(yè)績穩(wěn)中有升 落實(shí)提質(zhì)增效舉措,毛利潤率延續(xù)升勢 戰(zhàn)略布局成效顯著,戰(zhàn)新業(yè)務(wù)引領(lǐng)增長 以科技創(chuàng)新為引領(lǐng),提升企業(yè)核心競爭力 堅(jiān)持高質(zhì)量發(fā)展策略,塑強(qiáng)核心競爭優(yōu)勢...

關(guān)鍵字: 通信 BSP 電信運(yùn)營商 數(shù)字經(jīng)濟(jì)

北京2024年8月27日 /美通社/ -- 8月21日,由中央廣播電視總臺與中國電影電視技術(shù)學(xué)會聯(lián)合牽頭組建的NVI技術(shù)創(chuàng)新聯(lián)盟在BIRTV2024超高清全產(chǎn)業(yè)鏈發(fā)展研討會上宣布正式成立。 活動現(xiàn)場 NVI技術(shù)創(chuàng)新聯(lián)...

關(guān)鍵字: VI 傳輸協(xié)議 音頻 BSP

北京2024年8月27日 /美通社/ -- 在8月23日舉辦的2024年長三角生態(tài)綠色一體化發(fā)展示范區(qū)聯(lián)合招商會上,軟通動力信息技術(shù)(集團(tuán))股份有限公司(以下簡稱"軟通動力")與長三角投資(上海)有限...

關(guān)鍵字: BSP 信息技術(shù)
關(guān)閉
關(guān)閉