版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
nginxphp-fpm安裝配置
456
介 模塊化的結構。過濾器包括gzip,byteranges,chunkedresponses,以及SSI-filter。 或者FastCGI的多個子請求并發(fā)處理;SSLTLSSNIIMAP/POP3服務功能HTTPIMAP/POP3HTTPSMTP后端;POP3:POP3USER/PASS,APOP,AUTHLOGIN IMAP:IMAPLOGIN;SMTP:AUTH INCRAM-IMAPPOP3STARTTLSSTLS支持;BSD3.x,4.x,5.x,6.xi386;BSD5.x,6.xLinux2.2,2.4,2.6i386;Linux2.6Solaris8i386;Solaris9i386andsun4u;Solaris10i386;MacOSX(10.4)PPC;kqueue(BSD4.1+),epoll(Linux2.6+),rtsignals(Linux2.2.19+),/dev/poll(Solaris711/99+),select,以及poll支持;kqueue支持的不同功能包括EV_CLEAR,EV_DISABLE(臨時sendfile(BSD3.1+),sendfile(Linux2.2+),sendfile64(Linux2.4.21+),和sendfilev(Solaris87/01+)支持;輸入過濾(BSD4.1+)以及TCP_DEFER_ACCEPT(Linux2.4+)支持10,000HTTPkeep-alive2.5M內存。Memcached的GET接口; PCRE的rewrite基于客戶端IP地址和HTTP基本認證的控制PUTDELETE,MKCOL通過aio_read(
的套接字工作的實驗模塊,僅在BSD下 BSD4.x的實現基于Nginx主要的英語站點是AleksandarLazic為什么選擇Nginx是一個高性能的Web和反向服務器,它具有有很多非常優(yōu)越的特性作為Web服務器:相比Apache,Nginx使用更少的資源,支持的并發(fā)連接,體現更高Nginx50,000個并發(fā)連接數的響應,感謝Nginx為我們選擇了epollandkqueue作為開發(fā)模型.作為負載均衡服務器:NginxRailsPHPHTTP代理服務器對行服務。Nginx用C編寫,不論是系統(tǒng)資源開銷還是CPU使用效率都比Perlbal要好的多。作為郵件服務器:Nginx同時也是一個非常優(yōu)秀的郵件服務器(最早開發(fā)這個產品的目的之一也是作為郵件服務器),Last.fm描述了成功并且美妙的使用經驗。Nginx啟動特別容易,并且?guī)缀蹩梢宰龅?*24不間斷運行,即使運行數個月也不需要重新啟動。你還能夠在不間斷服務的情況下進行軟件版本的升級。 ++apt-getapt-getinstallbuild-essentialapt-getinstalllibtoolyum-yinstallyum-yinstallgccautomakeautoconflibtool安裝yumyuminstallgccgcc-, cdcdftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/的PCRE源碼包,使用下面命令編譯和安裝PCRE包:cdcdwgetftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.34.tar.gztar-zxvfpcre-8.34.tar.gzcdpcre-maketar-zxvfzlib-1.2.8.tar.gzcdzlib-1.2.8maketar-zxvfopenssl-安裝中一個,下面是把Nginx安裝到/usr/local/nginx tar-zxvfnginx-1.4.2.tar.gzcdnginx-1.4.2./configure--sbin-path=/usr/local/nginx/nginx--with-http_ssl_modulemake安裝成功后/usr/local/nginx fastcgi_params.defaultmime.types.default 80端口沒被其他程序占用,運行/usr/local/nginx/nginx命令來啟動netstatnetstat-ano|grepsudosudo打開瀏覽器此機器的IP,如果瀏覽器出現 etonginx!則表示Nginx已經安裝并libtool:compile:unrecognizedoption`-DHAVE_CONFIG_H'libtool:libtool:compile:unrecognizedoption`-DHAVE_CONFIG_H'libtool:compile:Try`libtool--help'formoreinformation.make[1]:***[pcrecpp.lo]Error1make[1]:Leavingdirectory`/usr/local/src/pcre-8.34'make:***[all]Error2apt-getapt-getinstallapt-getinstallbuild-essentialmakecleanmake:***Noruletomaketarget`build',neededby`default'../configure:error:SSLmodulesrequiretheOpenSSLYoucaneitherdonotenablethemodules,orinstalltheOpenSSLlibraryintothesystem,orbuildtheOpenSSLlibrarystaticallyfromthesourcewithnginxbyusing--with-openssl=apt-getinstallopensslapt-getapt-getinstallopensslapt-getinstalllibssl-devyumyum-yinstallopensslopenssl-
,存放服務器上的文件,也就是nginx的安 。默認用/usr/local/nginx--sbin-path=path設置nginx的可執(zhí)行文件的路徑,默認 --conf-path=path設置在nginx.conf配置文件的路徑。nginx允許使用不同的配置文件啟 時改變的文件名,在nginx.conf配置文件中使用PID指令。默認情況下,文件名 改變的文件名,在nginx.conf配置文件中使用的error_log指令。默認情況下,文件名 隨時改變的文件名,在nginx.conf配置文件中使用的access_log指令。默認情況下,文件名為 —
path—設置PCRE庫的源碼路徑。PCRE庫的源碼(版本4.4-8.30) 并解壓。其余的工作是Nginx的./configure和make來完成。正則表達式使用在location指令和ngx_http_rewrite_module模塊中。中,令)
path—設置的zlib庫的源碼路徑。要從zlib(版本1.1.3-1.2.5)的使用zlib。
—
select()支持的文件數量:--with-cc-opt="-D
--with-ld-opt="-L--with-ld-opt="-L<為-t不運行,而僅僅測試配置文件。nginx將檢查配置文件的語法的正確性,并嘗試打開配置文-vnginx-Vnginx可以使用信號系統(tǒng)來控制主進程。默認,nginxpid/usr/local/nginx/nginx.pid./configurepid指令,來改變該文TERM,TERM,nginx(ps-ef|grepps-ef|grepkillTERMnginxkill9nginxcatkill信號類型catkillkill-QUIT`catkill-sudo##<strong>psaux|egrep PID%CPU 22130.0 67842036?STATTIME0:00nginx:masterprocess#<strong>kill-15#<strong>#<strong>nginx-t-c2006/09/1613:07:10[info]15686#0:theconfigurationfile/etc/nginx/nginx.confsyntaxi2006/09/1613:07:10[info]15686#0:theconfigurationfile/etc/nginx/nginx.confwastest#<strong>psaux|egrep'(PID|nginx)'</strong> PID%CPU 22130.0 67842036?STATTIME0:00nginx:masterprocess<strong>#kill-HUPnginxHUP信號,它會嘗試先解析配置文件(如果指定配置文件,就使用指定的,否則使用默認的),成功的話,就應用新的配置文件(例如:重新打開日志文件或的套接字)。之后,nginx運行新的工作進程并從容關閉舊的工作進程。通知工作進程關閉閉。如果新的配置文件應用失敗,nginx將繼續(xù)使用舊的配置進行工作。nginx首先,使用新的可執(zhí)行程序替換舊的(最好做好備份),USR2(killUSR2.pid.oldbin(PPID1nginx:master33126nginx:worker33126nginx:worker33126nginx:worker33126nginx:master36264nginx:worker36264nginx:worker36264nginx:workernginx實例會同時運行,一起處理輸入的請求。要逐步停止舊的實例,你必須發(fā)送WINCH信號給舊的主進程,然后,它的工作進程就將開始從容關閉:PPIDVSZ11164nginx:master331261380nginx:workerisshuttingdown331261148nginx:master362641364nginx:worker362641364nginx:worker362641364nginx:workerPIDPIDPPID 13626433126362653626436266362643626736264VSZ11641148nginx:masterprocess/usr/local/nginx/sbin/nginxnginx:masterprocess1364kqreadnginx:workerprocess(nginx)1364kqreadnginx:workerprocess(nginx)1364kqreadnginx:workerprocessHUP它將在不重載配置文件的情況下啟動它的工作進程發(fā)送QUIT信號給新的主進程,要求其從容關閉其工作進程發(fā)送.oldbin.pid文件,這樣,一切PIDPPID VSZWCHAN 1362653626436266362643626736264
0.01148pausenginx:masterprocess0.01364kqreadnginx:workerprocess0.01364kqreadnginx:workerprocess0.01364kqreadnginx:workerprocess例如"8k"1m代表字節(jié)數計量.s秒mhd日w周M一個月30y年365例如"1h30m""1y6M""130分1年零6個月 優(yōu)化考慮到保存鍵及其值的hash表單元的大小不至于超出設定參數(hashbucketsize),在啟直到hash表超過參數(hashmaxsize)的大小才重新進行選擇.對于大多數hash表都有指令來 所控制的。參數hashbucketsize總是等于hash表的大小,并hash表鍵值成為可能。如果hashbucketsize等于一路處理器緩存的大小,那么在查找鍵的時單元中查找鍵值。因此,如果Nginx給出需要增大hashmaxsize或hashbucketsize的提
和--without-
kqueue-高效的方法,使用 BSD4.1+,OpenBSD2.9+,NetBSD2.0和, 小。可是從Linux內核版本2.6.6-mm2開始,這個參數就不再使用了,并且對于每個進程 /dev/poll高效的方法,使用于Solaris711/99+HP/UX11.22eventport6.5.15Tru64UNIXeventport-高效的方法,使用于Solaris10.為了防止出現內核的問題,有必要安裝這個安全補丁。常見問題[#notwork某些東東不工作(URL重寫,,路徑,...)][#other有沒有其它類似的Web服務器][#chroot對于chroot的支持是否在計劃之中?]測試IMAP模塊,而不只是關于IMAP的只言片語啊?] 某些東東不工作(URL重寫,,路徑,請仔細閱讀[NginxDebugging]并且逐行查看錯誤日志。?大體上來說nginx主要用于反向加速而不是像squid那樣做為常規(guī)服務器。Nginx的最大優(yōu)勢在于高負載情況下內存和CPU的低消耗。我不認為squid能給你帶來比nginx更好的性Nginx使用什么算法來實現負載均衡它能實現基于連接數的負>我能關閉從服務器到后端服務器的緩存嗎或者使用上傳進(2007-Apr-26)還沒有辦法關閉到后端服務器的緩存調試Nginx的一個級特性就是你能使用debug_connection指令只調試某些連接。這個設置只有是你使用--with-debug編譯的nginx才有效。調試 Nginx的基本功能的指令[#daemondaemon][#error_logerror_log][#includeinclude][#lock_filelock_file][#pidpid][#ssl_enginessl_engine][#userusergroup][#worker_cpu_affinityworker_cpu_affinity][#worker_priorityworker_priority][#worker_processesworker_processes][#worker_rlimit_coreworker_rlimit_core][#worker_rlimit_nofileworker_rlimit_nofile][#working_directoryworking_directory]語法:*daemonon|缺省值daemondaemonDonotusethe"daemon"and"master_process"directivesinaproductionmode,daemonoptionsaremainlyusedfordevelopmentonly.Youcandaemonmaster_processmodewithrunit/daemontoolshoweveryoucan'tdoagracefulmaster_process
safelyin語法:*debug_pointsstop|缺省值debug_pointsdebug_pointsTherearesomeassertionpointsinsidenginxthatallowtostopnginxtoattachthedebugger,ortoabortandtocreatethecorefile.語法:*error_logfiledebug|info|notice|warn|error|crit缺省值Nginx添 ,你還能夠使用以下配置error_logerror_logLOGFILE[debug_core|debug_alloc|debug_mutex|]:|debug_http|debug_imap語法:*includefile|缺省值 includeinclude語法:*lock_file缺省值:*compile-timelock_filelock_filenginxusesacceptmutextoserializeaccept()syscalls.Ifnginxisbuiltbygcc,InC++,orSunProC++compilersoni386,amd64,sparc64,andppc64,thennginxusestheatomicinstructionstoimplementthemutex.Inothercasesthelockfilewouldbeused.語法:*master_processon|缺省值master_processmaster_processDonotusethe"daemon"and"master_process"directivesinaproductionmode,theseoptionsaremainlyusedfordevelopmentonly.語法:*pid缺省值:*compile-timeoption*pidpidcat進程id文件??梢允褂胟ill-cat語法:*ssl_engine缺省值:*system
Hereyoucansetyourpreferredopensslengineifanyavailable.Youcanfigureoutwhichonedoyouhavewiththecommandlinetool:opensslopensslengine-例如$$opensslengine-(cryptodev)BSDcryptodev:[available(dynamic)Dynamicengineloading:[unavailabletimer_resolutiontimer_resolutionThedirectiveallowstodecreasenumbergettimeofday()syscalls.Bydefaultgettimeofday()iscalledaftereachreturnfromkevent(),epoll,/dev/poll,select(),poll().Butifyouneedanexacttimeinlogswhenlogging$upstream_response_time,or$msecvariables,thenyoushoulduse 語法:*useruser缺省值:*nobodyuserwwwuserwww[Linuxonly.WiththisoptionyoucanbindtheworkerprocesstoaCPU,itcallsForexample,worker_cpu_affinity000100100100BindeachworkerprocesstooneCPUworker_cpu_affinity0101BindthefirstworkertoCPU0/CPU2,bindthesecondworkertoCPU1/CPU3.ThisissuitableforHTT.缺省值Withthisoptionyoucangivetoallworkerprocessesthepriority(nice)youneed/wish,itcallsworker_processesworker_processesnginxhastheabilitytousemorethanoneworkerprocessforseveralreasons:tousetodecreaselatencywhenworkersblockendondisktolimitnumberofconnectionsperprocesswhenselect()/poll()isss
fromtheeventsectionsallowsyoumax_s=worker_processes*缺省值umsizeofcorefileper語法worker_rlimit_nofilelimit缺省值Specifiesthevalueforumfiledescriptorsthatcanbeopenedbythis:(SinceLinux2.6.8)SpecifiesthelimitonthenumberofsignalsthatmaybequeuedfortherealuserIDofthecallingprocess.語法working_directorypath缺省值--Thisistheworkingdirectoryfortheworkers.It'susedforcorefilesonly.nginxusesabsolutepathsonly,allrelativepathsinconfigurationfilesarerelativetoSyntax:*accept_mutex[on|offSyntax:*debug_connection[ip|Since0.3.54thisoptionsupportCIDRaddressThisoptiongivesyoutheabilitytowritedebuglogonlyforthesofthisIP/NET.Severaldifferentdirectivesarepossible.error_logerror_log/var/log/nginx/errors;events{ }Thesedirectivesspecifyhowmanyeventsmaybepassedto/fromkernel,usingappropriateThe valuesare32,therestareSyntax:*multi_accept[on|offtriestoaccept()asmanyconnectionsaspossibleafternginxgetsnotificationaboutanewconnection.nginxusestwosignalswhenthesignalnumber.Thesecondisplus1.
methodisused.ThedirectivespecifiedtheBy isSIGRTMIN+10Thesedirectivesspecifieshowtohandlertsigqueueoverflows.Whenoverflowoccurrednginxflushesrtsigqueue,thenithandleseventsswitchingbetweenpoll()andrtsig.poll()handlesconsecutivelyallunhandledevents,whilertsigperiodicalydrainsqueuetopreventanewoverflow.Whenoverflowishandledcompley,nginxswitchestortsigmethodagain.Thertsig_overflow_eventsspecifiesthenumberofeventstobepassedviapoll().Thedefaultis16.Thertsig_overflow_testspecifiesafterwhichnumberofeventshandledbypoll()nginxwilldrainsrtsigqueue.Thedefaultis32.Thertsig_overflow_thresholdworksinLinux2.4.xonly.BeforetodrainrtsigqueuenginxlooksinakernelhowthequeueisfilledupThedefaultis1/10."rtsig_overflow_threshold3"meansSyntax:*use[kqueue|rtsig|epoll|/dev/poll|select|poll|eventport如果 你可以在這里查看可用的模型以及如何在 s=worker_processes*s=worker_processes*Sinceabrowseropens2connectionsbydefaulttoaserverandnginxusesthefds(filedescriptors)fromthesamepooltoconnecttotheupstreambackend Thisdirectiveassignsapathtobeusedfortheindicatedlocation.Notethatitmaylooksimilartothe directive,buttherootdoesn'tchange,justthefilesystempathusedfortherequest.Forlocationlocation/i/ }Therequest"/i/top.gif"willreturnthefile"/spool/w3/images/top.gif".Itispossibletousevariablesintherecementpath. directivecannotbeusedinsidearegex-specified .Ifyouneedtodothisyoumustuseacombinationof ThedirectiveenablestostorearequestbodyinaPleasenotethatthefileattherequestcompletionwillnotberemovedifthedirectiveisThisdirectivecanbeusedfordebuggingandfortheEmbeddedPerlmodule.
methodinThedirective(0.7.58+)specifieswhethertokeepthewholebodyinasinglerequestbuffer.Thedirectiveis mendedwhenusingthevariable$request_bodytoreducetheoperationsofcopying.default:*8k/16k*context:*http,server,location*ThedirectivespecifiestherequestbodybufferIftherequestbodyismorethanthebuffer,thentheentirerequestbodyorsomepartiswritteninatemporaryfile.Thedefaultsizeisequaltotwopagessize,dependingontformitiseither8Korsyntax:*_body_temp_pathdir-path[level1[level2[level3ThedirectiveassignsthedirectoryforstoringthetemporaryfilesinitwiththebodyoftheIn ahierarchyofsubdirectoriesuptothreelevelsareFor_body_temp_path_body_temp_path_temp1ThedirectorystructurewillbelikeDirectivesetsthereadtimeoutfortherequestbody Thetimeoutissetonlyifabodyisnotgetinonereadstep.Ifafterthistimethe nothing,nginxreturnserror"Requesttimeout"(408).DirectivesetstheheaderbuffersizefortherequestheaderfromFortheoverwhelmingmajorityofrequestsitiscompleysufficientabuffersizeofHoweverifabigisintherequest-headerortherequesthascomefromawap-theheadercannotbecedin1K,therefore,therequest-headeroralineofrequest-headerisnotlocatedcompleyinthisbuffernginxallocateabiggerbuffer,thesizeofthebiggerbuffercanbesetwiththeinstructionlarge__header_buffers.DirectiveassignstimeoutwithreadingofthetitleoftherequestofThetimeoutissetonlyifaheaderisnotgetinonereadstep.Ifafterthistimethesendnothing,nginxreturnserror"Requesttimeout"(408).Directiveassignsthe umacceptedbodysizeof request,indicatedbythelineintheheaderofrequest.Ifsizeisgreaterthegivenone,thenthe getstheerror"RequestEntityTooLarge"Itisnecessarytokeepinmindthatthebrowsersdonotknowhowtocorrectlyshowthisdefault:*default_typetext/in*context:*http,server,location*AssignsthedefaultMIME-typetobeusedforfileswherethestandardMIMEmapdoesn'tspecifyanything.location=.paclocation=.pacdefault_typeapplication/x-}location= d.datrewrite.default_typeapplication/x-}syntax:*directio[size|off]*default:*directiooff*ThedirectiveenablesuseofflagsO_DIRECT(BSD,Linux),F_NOCACHE(MacOSX)ordirectio()function(Solaris)forreadingfileswithsizegreaterthanspecified.Thisdirectivedisablesuseofsendfileforthisrequest.Thisdirectivemaybeusefulforbigfiles:directiodirectiosyntax:*error_pagecode[code...][=|=answer-code]uri|context:*http,server,location,ifinThedirectivespecifiestheURI,whichwillbeshowedfortheerrorsindicated. 502503=Furthermore,itispossibletochangethecodeofanswertoanother,forerror_pageerror_page404=200IfanerroneousanswerisprocessedbytheproxiedorFastCGIserverandthisservercanreturnthedifferentanswercodes,forexample,200,302,401or404,thenitispossibletohidethecodereturned: 404=Ifyouwishtoreturntheerrorcodeas-is,OMITthe=fromtheerror_page 404default:*if_modified_sinceexact*context:*http,server,location*Thedirective(0.7.24)defineshowtocomparetimeoffilemodificationandtimeinrequestheader"If-Modified-Since":off—don'tcheck"If-Modified-Since"requestheader(0.7.34);exact—exactmatch;before—filemodificationtimeshouldbelessthantimein"If-Modified-Since"requestsyntax:*indexfile[file...]*default:*indexindex.html*Directivedeterminesthefile(s)whichwillbeusedastheindex.It'spossibletousevariablesinthenameoffile.Thepresenceofthefilesischeckedintheorderoftheirenumeration.Afilewithanabsolutepathcanbeputattheend.Exampleusingavariable:indexindexindex.$geo.htmlindex.0.htmlIfyouwanttoautomaticallygenerateanindexfromadirectorylisting,useautoindexinternalindicatesthatthematchinglocationcanbeusedonlyforsocalled"internal"Forexternalrequestsitwillreturntheerror"Notfound"(404).Internalrequestsarethefollowing:requestsredirectedbytheinstructionsubrequestscreatedbythecommandincludevirtualofthe"ngx_http_ssi_module"requestschangedbytheinstructionrewriteofthe"ngx_http_rewrite_module"moduleAnexampletopreventsfetchingerrorpagesdirectly:error_pageerror_page404/404.html;location/404.html{}Nginx0.7.xintroducesanewsyntaxforinternallocationlocation/root/var/www/html;error_page404@40x;}location@40xroot}syntax:*keepalive_timeout[time]*default:*keepalive_timeout75*context:*http,server,location*Thefirstparameterassignsthetimeoutforkeep-aliveconnectionswiththe.Theserverwillcloseconnectionsafterthistime.Theoptionalsecondparameterassigns valueintheKeep-Alive:oftheresponse.Thisheadercanconvincesomebrowserstoclosetheconnection,sothattheserverdoesnothaveto.Withoutthisparameter,Keep-Alive:doesnotsenda
header(thoughthisisnotwhatmakesaconnectionTheparameterscandifferfromeachNotesonhowbrowsershandle MSIEandOperaignorethe"Keep-Alive:timeout="MSIEkeepstheconnectionaliveforabout60-65seconds,thensendsaTCPRST.Operakeepstheconnectionaliveforalongtime.MozillakeepstheconnectionaliveforNplusabout1-10seconds.KonquerorkeepstheconnectionaliveforaboutNseconds.syntax:*keepalive_requestsn*context:*http,server,location*Numberofrequestswhichcanbemadeoverakeep-alivedefault:*large__header_buffers44k/8k*context:*http,server*Directiveassignstheumnumberandsizeofbuffersforlargeheaderstoreadfromrequest.Therequestlinecannotbebiggerthanthesizeofonebuffer,ifthesendabiggerheadernginxreturnserror"RequestURItoolarge"(414).Thelongestheaderlineofrequestalsomustbenotmorethanthesizeofonebuffer,otherwisethegettheerror"Badrequest"(400).BuffersareseparatedonlyasBydefaultthesizeofonebufferisequaltothesizeofpage,dependingontformthiseither4Kor8K,ifattheendofworkingrequestconnectionconvertstostatekeep-alive,thenthesebuffersared.DirectivelimitsHTTP-methods,accessibleinsideForthelimitationcanbeusedthedirectivesofmodulesngx_http_access_moduleandlimit_exceptlimit_except{allow/32;deny}context:*http,server,location,ifinDirectiveassignsthespeedoftransmissionoftheanswerto .Speedisassignedinthebytespersecond.Limitationworksonlyforoneconnection,i.e.,if opens2connections,thentotalvelocitywillbe2timeshigherthenthelimitset.Ifitisnecessarytolimitspeedforthepartofthesattheserverlevel,basedonsomekindofcondition-thenthisdirectivedoesnotapply.Insteadyoushouldspecifythelimitbyassigningthevaluetothe$limit_ratevariable,asshownbelow:serverserverif($slow)set$limit_rate}}context:*http,server,location,ifinThedirectivelimitsspeedonlyafterthefirstpartwaslimit_rate_afterlimit_rate_after1m;limit_rate100k;syntax:*listenaddress:port[default[backlog=num|rcvbuf=size|sndbuf=size|accept_filter=filter|deferred|bind|ssl]]*Thelistendirectivespecifiestheaddressandportacceptedbytheenclosingserver{...}block.Itispossibletospecifyonlyanaddress,onlyaport,oraservernameastheaddress.listenlistenlistenlisten8000;listen*:8000;listenIPv6address(0.7.36)aresetinsquarelistenlistenlistenWhenLinux(incontrasttoBSD)bindsIPv6[::],itwillalsobindthecorrespondingIPv4address.IfothernonIPv6serverdefinitionsalreadyusedthis,thebindwillfail.Byusingexplicitaddressesinsteadof[::]thiswillnotbeaproblem.ItisalsopossibletospecifythatthislistendirectiveisonlytobindtheIPv6addresswithuseofthe"defaultipv6only=on"option.Notethatthisonlyaffectthislistendirective,thesameserver{...}blockmayverywelllistentoIPv4aswell,specifiedbyotherlistendirectives.listenlistenlisten[::]:80defaultIfonlyaddressisgiven,thedefaultportisIfthedirectivehasthedefaultparameter,thentheenclosingserver{...}blockwillbethedefaultserverfortheaddress:portpair.Thisisusefulforname-basedvirtualhostingwhereyouwishtospecifythedefaultserverblockforhostnamesthatdonotmatchany[#server_nameserver_name]directives.Iftherearenodirectiveswiththeparameter,thenthedefaultserverwillbethefirstserverblockinwhichthepairappears. directiveacceptsseveralparameters,specifictothesystemcalls .Theseparametersmustfollowthe backlog=num--isassignedparameterbacklogin-
.Bydefaultbacklogrcvbuf=size--assignedtotheparameter forthelisteningsocket.sndbuf=size--assignedtotheparameter forthelisteningsocket.accept_filter=filter--isassignednameaccept-filter..ItworksonlytoBSD,itispossibletousetwofilters-- .Onthesignal-HUPaccept-filteritispossibletochangeonlyinthequitelastversionsBSD:6.0,5.4-STABLEand4.11-STABLE.deferred--indicatestousethatpostponedaccept(2)Linux.theaidofoption
.bind--indicatesthatitisnecessaryto.forthispairofaddress:port.Thefactisthatifaredescribedseveraldirectiveslistenwiththeidenticalport,butbydifferentaddressesandoneofthedirectiveslistenlistenstoonalladdressesforthisport(:port),thennginxwillmakebind(2)onlyto:port.Itisnecessarytoconsiderthatinthiscasefordeterminingtheaddress,onwhichtheconnectionsarrive,isdonethesystemcallgetsockname().Butifareusedparametersbacklog,rcvbuf,sndbuf,accept_filterordeferred,thenitisalwaysdoneseparayforthispairofaddress:portbind(2).ssl--parameter(0.7.14)notrelatedtolisten(2)andbind(2)syscalls.butinsteadspecifiesthatconnectionsacceptedonthisportshouldworkinSSLmode.ThisallowstospecifycompactconfigurationsforserversworkingwithbothHTTPandHTTPS.Forexample:listenlistenlisten443defaultExampleoftheuseofthelistenlistendefaultaccept_filter=datareadysyntax:*location[=|~|~|^~]/uri/{...ThisdirectiveallowsdifferentconfigurationsdependingontheURI.Itcanbeconfiguredusingbothlilstringsandregularexpressions.Touseregularexpressions,youmustusetheaprefix:forcaseinsensitiveforcasesensitiveTodeterminewhichlocationdirectivematchesaparticularquery,thelilstringsarecheckedfirst.Lilstringsmatchthebeginningportionofthequeryandarecase--themostspecificmatchwillbeused(seebelowonhownginxdeterminesthis).regularexpressionsarecheckedintheorderdefinedintheconfigurationfile.Thefirstregularexpressiontomatchthequerywillstopthesearch.Ifnoregularexpressionmatchesarefound,theresultfromtheli lstringsearchisused.Therearetwowaystomodifythisbehavior.Thefirstistousetheprefix"=",whichmatchesanexactqueryonly.Ifthequerymatches,thensearchingstopsandtherequestishandled y.Forexample,iftherequest"/"occursfrequently,thenusing"location=/"willexpeditetheprocessingofthisrequest.Thesecondistousetheprefix .Thisprefixisusedwithali lstringand lsnginxtonotcheckregularexpressionsifthepathprovidedisamatch.Forinstance,"location/images/"wouldhaltsearchingifthequerybeginswith/images/-allregularexpressiondirectiveswouldnotbechecked.Tosummarize,theorderinwhichdirectivesarecheckedisasDirectiveswith prefixthatmatchthequeryexactly.Iffound,searchingAllremainingdirectiveswithconventionalstrings.Ifthismatchusedthesearchingstops.Regularexpressions,intheordertheyaredefinedintheconfiguration
If#3yieldedamatch,thatresultisused.Otherwise,thematchfrom#2isItisimportanttoknowthatnginxdoesthecomparisonagainstdecodedURIs.Forexample,ifyouwishtomatch"/images/%20/test",thenyoumustuse"/images//test"todeterminethelocationlocation=/#matchesthequery/only.[configurationA]}location/#matchesanyquery,sinceallqueriesbeginwith/,butregular#expressionsandanylongerconventionalblockswillbe#matched[configurationB}location^~/images/#matchesanyquerybeginningwith/images/andhaltssearching,#soregularexpressionswillnotbechecked.[configurationC}location~*\.(gif|jpg|jpeg)$#matchesanyrequestendingingif,jpg,orjpeg.However,all#requeststothe/images/directorywillbehandledby#ConfigurationC.[configurationD]}Example/->configuration /images/1.gif->configuration s/1.jpg->configurationNotethatyoucoulddefinethese4configurationsinanyorderandtheresultswouldremainthesame.Whilenestedlocationsareallowedbytheconfigurationfileparser,theiruseisdiscouragedandmayproduceunexpectedresults.HownginxDeterminesWhichPathMostuserswillnotneedtoknowhownginxinternallydetermineswhichpathtouse-knowthatitwillchoosethe"mostspecific"matchforyourURIinaspeedyandefficientmanner.Forthosethatarecurious,however,readon.Allpathstringsaresortedalphabetically.nginxthenproceedstosearchdownthelistlookingformatchesuntiltherequestURIhasa"higher"valuethenthecurrentstringinthesortedlist.Thisisdeterminedusingthefamilyof functions-once returns1,thensearchingstops.Oncesearchingstops,thelaststringwhichmatchedisused.Forexample,letssaywehavethefollowing//Now,letssaytheservergetsthepath"/az".nginxwouldbeginsearchdownthislist.First,"/"wouldmatch,but"/islessthan"/az"sosearchingcontinues."/a"alsomatches,but"/a"isstilllessthan"/az"sowecontinueagain."/apple"doesnotmatch.Thenextstring,"/banana",isgreaterthan"/az"sosearchingstopsandthelastmatch,"/a",wouldbeused.NamedLaterversionsofNginx(>0.7.x)haveNamedLocations.Thesearelocationblocksthatstartwithan@symbol,andaretreatedsimilartointernallocationsexceptthattheypreservetheoriginalURIoninternalredirectsforerror_pageortry_filesdirectives.locationlocation/try_files@joomla}location@joomlarewrite^(.*)$/index.php?q=$1}default:*log_not_foundon*context:*http,server,location*Thedirectiveenablesordisablesmessagesinerror_logaboutfilesnotfoundondefault:*log_subrequestoff*context:*http,server,location*Thedirectiveenablesordisablesmessagesinaccess_logaboutsub-requestssuchasrewriterulesand/orSSIrequests.default:*msie_paddingon*context:*http,server,location*Thisdirectiveenablesordisablesthethemsie_paddingfeatureforMSIEbrowsers.Whenthisisenabled,nginxwillpadthesizeoftheresponsebodytoaminimumof512bytes,forresponseswithastatuscodeaboveorequalto400.Thepaddingpreventstheactivationof"friendly"HTTPerrorpagesinMSIE,soastonothidethemore-informativeerrorpagesfromtheserver.NotethatChromium/Chromehave"friendly"HTTPerrorpagesaswell,butthisfeaturewillnotsendthemthepadding.syntax:*msie_refresh[on|off]*default:*msie_refreshoff*Thisdirectiveallowsorforbidsissuing insteadofng forsyntax:*open_file_cachemax=N[inactive=time]|Thedirectivesetsthecacheactivityon.TheseinformationcanbeOpenfiledescriptors,informationwiththeirsizeandmodificationtime;Informationabouttheexistenceofdirectories;Errorinformationwhensearchesforafile-nofile,donothaverightstoread,etc.Seealsoopen_file_cache_errorsOptionsspecifiestheumnumberofentriesinthecache.Whenthecacheoverflows,thelongest-useditems(LRU)willberemoved;-specifiesthetimewhenthecacheditemisremoved,ifithasnotbeendownloadedduringthattime,thedefaultis60seconds;prohibitsthecacheopen_file_cacheopen_file_cachemax=1000inactive=20s; open_file_cache_min_uses2; syntax:*open_file_cache_errorson|off*default:*open_file_cache_errorsoff*context:*http,server,location*ThedirectivespecifiestocacheerrorsornotwhensearchingaThedirectivedefinestheminimumusenumberofafilewithinthetimespecifiedinthedirectiveparameterinactiveinopen_file_cache.?Ifusemorethanthenumber,thefiledescriptorwillremainopeninthecache.default:*open_file_cache_valid60*context:*http,server,location*Thedirectivespecifiesthetimewhenneedtocheckthevalidityoftheinformationabouttheiteminopen_file_cache.syntax:*optimize_server_names[on|off]*default:*optimize_server_nameson*context:*http,server*Directiveactivatesordeactivatesoptimizationofhostnamechecksforname-basedvirtualInparticular,thecheckinfluencesthenameofthehostusedinredirects.Ifoptimizationison,andallname-basedserverslisteningononeaddress:portpairhaveidenticalconfiguration,thennamesarenotcheckedduringrequestexecutionandredirectsusefirstservername.Ifredirectmustusehost
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024年股權激勵合同:股權獎勵與業(yè)績掛鉤條款3篇
- 2025年度濾袋材料費用合同采購與項目進度管理合同3篇
- 2025年度網絡安全防護設備采購合同范本與安全等級保護2篇
- 學生校園欺凌情況調查問卷
- 敢于擔當善于化解難題體會
- 護理人力資源管理1
- 黨史知識競賽題庫及答案-一起學習黨史吧
- 八一南昌起義的意義是什么
- 2024版地方特色農產品購銷合作合同版
- 2024集體土地租賃協(xié)議書
- 事業(yè)單位登記管理講座課件
- 柴油加氫設備-加氫循環(huán)氫壓縮機
- 中小學德育工作指南考核試題及答案
- 雪夜的老人閱讀答案6篇
- 2022數學課程標準解讀及實踐:八下平行四邊形大單元設計
- 昌樂二中271課堂教學模式
- 深基坑變形監(jiān)測方案
- 衛(wèi)生專業(yè)技術資格任職聘用證明表
- GB/T 3077-2015合金結構鋼
- GB/T 25003-2010VHF/UHF頻段無線電監(jiān)測站電磁環(huán)境保護要求和測試方法
- GB/T 15326-1994旋轉軸唇形密封圈外觀質量
評論
0/150
提交評論