ChsCommandLine
Nginx涓枃鏂囨。 > 杩愯鍜屾帶鍒 Nginx - 鍛戒护琛屽弬鏁板拰淇″彿
涓嶅儚璁稿鍏朵粬杞欢绯荤粺锛孨ginx 浠呮湁鏁颁釜鍛戒护琛屽弬鏁帮紝瀹屽叏閫氳繃閰嶇疆鏂囦欢鏉ラ厤缃紙鎯宠薄涓涓嬶級銆
- [#options 閫夐」]
- [#example 绀轰緥]
- [#lncus 浣跨敤淇″彿鍔犺浇鏂扮殑閰嶇疆]
- [#utnbotf 骞虫粦鍗囩骇鍒版柊鐨勪簩杩涘埗浠g爜]
Contents |
[edit] 閫夐」
-c </path/to/config> 涓 Nginx 鎸囧畾涓涓厤缃枃浠讹紝鏉ヤ唬鏇跨己鐪佺殑銆
-t 涓嶈繍琛岋紝鑰屼粎浠呮祴璇曢厤缃枃浠躲俷ginx 灏嗘鏌ラ厤缃枃浠剁殑璇硶鐨勬纭э紝骞跺皾璇曟墦寮閰嶇疆鏂囦欢涓墍寮曠敤鍒扮殑鏂囦欢銆
-v 鏄剧ず nginx 鐨勭増鏈
-V 鏄剧ず nginx 鐨勭増鏈紝缂栬瘧鍣ㄧ増鏈拰閰嶇疆鍙傛暟銆
[edit] 绀轰緥
杩欎釜绀轰緥浠呮祴璇曟寚瀹氫綅缃殑閰嶇疆鏂囦欢鏄惁姝e父锛屽苟缁欏嚭鎻愮ず銆
/usr/bin/nginx -t -c ~/mynginx.conf
鍦╳indows涓嬪惎鍔╪ginx鐨勬壒澶勭悊鏂囦欢(somaceo鎻愪緵) 鍦ㄧ綉涓婁笅杞絧rocess.exe鍜孯unHiddenConsole.exe鏀惧湪nginx瀹夎鐩綍涓嬶紝骞跺缓绔嬩竴涓 鍚姩nginx.bat 鏂囦欢锛屽唴瀹瑰涓嬶紝璺緞绛夊湴鍧鍙傛暟鎸夎嚜宸辩殑瀹為檯鎯呭喌鍙互淇敼銆
@echo off cd nginx>nul echo 姝e湪鍋滄Nginx杩涚▼...... process.exe -k nginx.exe>nul echo 姝e湪鍋滄PHP(FastCGI)杩涚▼...... rem process.exe -k php-cgi.exe>nul echo Nginx+PHP宸插仠姝€ @echo off cd nginx>nul echo 姝e湪鍚姩PHP(FastCGI)杩涚▼...... echo 璺緞浣跨敤鐩稿鏈壒澶勭悊鏂囦欢鐨勭浉瀵硅矾寰勶紝锛堜篃鍙互浣跨敤缁濆璺緞锛屼絾涓嶅埄浜庢嫹璐濊縼绉伙級锛屾寚鏄庡紩鐢ㄧ殑鍦板潃:绔彛锛屽姞杞界壒瀹氫綅缃殑php.ini鏂囦欢銆傚鏋滀笉鐢╬hp杩欓儴鍒嗗氨涓嶈鐞嗕簡銆 RunHiddenConsole.exe ..\..\PHP\php-cgi.exe -b 127.0.0.1:9000 -c ..\..\PHP\php.ini echo PHP宸插惎鍔ㄣ echo nginx 灏嗘鏌ユ寚瀹氱殑閰嶇疆鏂囦欢鐨勮娉曠殑姝g‘鎬э紝骞跺皾璇曟墦寮閰嶇疆鏂囦欢涓墍寮曠敤鍒扮殑鏂囦欢銆 nginx.exe -t -c conf/nginx.conf echo -v 鏄剧ず nginx 鐨勭増鏈倂瀛楁湁澶у皬涔嬪垎 鍙傝冿細http://wiki.nginx.org/NginxChsCommandLine nginx.exe -v echo 涓嬩竴姝ュ惎鍔∟ginx杩涚▼...... echo 姝e湪鍚姩Nginx杩涚▼...... nginx.exe -c conf/nginx.conf echo Nginx+PHP宸插惎鍔ㄣ rem 鐢╬ause鏆傚仠淇濈暀鍛戒护绐楀彛鐪嬬湅鏈夋病鏈夐敊璇彂鐢 pause exit
[edit] 閫氳繃绯荤粺鐨勪俊鍙锋帶鍒 Nginx
鍙互浣跨敤淇″彿绯荤粺鏉ユ帶鍒朵富杩涚▼銆傞粯璁わ紝nginx 灏嗗叾涓昏繘绋嬬殑 pid 鍐欏叆鍒 /usr/local/nginx/logs/nginx.pid 鏂囦欢涓傞氳繃浼犻掑弬鏁扮粰 ./configure 鎴栦娇鐢 pid 鎸囦护锛屾潵鏀瑰彉璇ユ枃浠剁殑浣嶇疆銆
涓昏繘绋嬪彲浠ュ鐞嗕互涓嬬殑淇″彿锛
TERM, INT | 蹇熷叧闂 |
QUIT | 浠庡鍏抽棴 |
HUP | 閲嶈浇閰嶇疆 鐢ㄦ柊鐨勯厤缃紑濮嬫柊鐨勫伐浣滆繘绋 浠庡鍏抽棴鏃х殑宸ヤ綔杩涚▼ |
USR1 | 閲嶆柊鎵撳紑鏃ュ織鏂囦欢 |
USR2 | 骞虫粦鍗囩骇鍙墽琛岀▼搴忋 |
WINCH | 浠庡鍏抽棴宸ヤ綔杩涚▼ |
灏界浣犱笉蹇呰嚜宸辨搷浣滃伐浣滆繘绋嬶紝浣嗘槸锛屽畠浠篃鏀寔涓浜涗俊鍙凤細
TERM, INT | 蹇熷叧闂 |
QUIT | 浠庡鍏抽棴 |
USR1 | 閲嶆柊鎵撳紑鏃ュ織鏂囦欢 |
[edit] 浣跨敤淇″彿鍔犺浇鏂扮殑閰嶇疆
Nginx 鏀寔鍑犱釜淇″彿锛岃兘鍦ㄥ畠杩愯鏃舵帶鍒跺叾鎿嶄綔銆傚叾涓渶鏅氱殑鏄 15 锛岀敤鏉ヤ腑姝㈣繍琛岀殑杩涚▼锛
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
鑰屾渶鏈夎叮鐨勬槸鑳藉钩婊戞敼鍙 nginx 閰嶇疆鐨勯夐」锛堣娉ㄦ剰锛屽湪閲嶈浇鍓嶏紝瑕佸厛娴嬭瘯涓涓嬮厤缃枃浠讹級锛
2006/09/16 13:07:10 [info] 15686#0: the configuration file /etc/nginx/nginx.conf syntax is ok 2006/09/16 13:07:10 [info] 15686#0: the configuration file /etc/nginx/nginx.conf was tested successfully 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
褰 nginx 鎺ユ敹鍒 HUP
淇″彿锛屽畠浼氬皾璇曞厛瑙f瀽閰嶇疆鏂囦欢锛堝鏋滄寚瀹氶厤缃枃浠讹紝灏变娇鐢ㄦ寚瀹氱殑锛屽惁鍒欎娇鐢ㄩ粯璁ょ殑锛夛紝鎴愬姛鐨勮瘽锛屽氨搴旂敤鏂扮殑閰嶇疆鏂囦欢锛堜緥濡傦細閲嶆柊鎵撳紑鏃ュ織鏂囦欢鎴栫洃鍚殑濂楁帴瀛楋級銆備箣鍚庯紝nginx 杩愯鏂扮殑宸ヤ綔杩涚▼骞朵粠瀹瑰叧闂棫鐨勫伐浣滆繘绋嬨傞氱煡宸ヤ綔杩涚▼鍏抽棴鐩戝惉濂楁帴瀛椾絾鏄户缁负褰撳墠杩炴帴鐨勫鎴锋彁渚涙湇鍔°傛墍鏈夊鎴风鐨勬湇鍔″畬鎴愬悗锛屾棫鐨勫伐浣滆繘绋嬭鍏抽棴銆傚鏋滄柊鐨勯厤缃枃浠跺簲鐢ㄥけ璐ワ紝nginx 灏嗙户缁娇鐢ㄦ棫鐨勯厤缃繘琛屽伐浣溿
RequestForReviewCategory -- (Request For Review: Just What Happens With The Worker Processes at a HUP? -Olle)
[edit] 骞虫粦鍗囩骇鍒版柊鐨勪簩杩涘埗浠g爜
浣犲彲浠ュ湪涓嶄腑鏂湇鍔$殑鎯呭喌涓 - 鏂扮殑璇锋眰涔熶笉浼氫涪澶憋紝浣跨敤鏂扮殑 nginx 鍙墽琛岀▼搴忔浛鎹㈡棫鐨勶紙褰撳崌绾ф柊鐗堟湰鎴栨坊鍔/鍒犻櫎鏈嶅姟鍣ㄦā鍧楁椂锛夈
棣栧厛锛屼娇鐢ㄦ柊鐨勫彲鎵ц绋嬪簭鏇挎崲鏃х殑锛堟渶濂藉仛濂藉浠斤級锛岀劧鍚庯紝鍙戦 USR2 (kill -USR2 pid)淇″彿缁欎富杩涚▼銆備富杩涚▼灏嗛噸鍛藉悕瀹冪殑 .pid 鏂囦欢涓 .oldbin (姣斿锛/usr/local/nginx/logs/nginx.pid.oldbin)锛岀劧鍚庢墽琛屾柊鐨勫彲鎵ц绋嬪簭锛屼緷娆″惎鍔ㄦ柊鐨勪富杩涚▼鍜屾柊鐨勫伐浣滆繘绋嬶細
- PID PPID USER %CPU VSZ WCHAN COMMAND
33126 1 root 0.0 1164 pause nginx: master process /usr/local/nginx/sbin/nginx 33134 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) 36266 36264 nobody 0.0 1364 kqread nginx: worker process (nginx) 36267 36264 nobody 0.0 1364 kqread nginx: worker process (nginx) </pre>
鍦ㄨ繖鏃讹紝涓や釜 nginx 瀹炰緥浼氬悓鏃惰繍琛岋紝涓璧峰鐞嗚緭鍏ョ殑璇锋眰銆傝閫愭鍋滄鏃х殑瀹炰緥锛屼綘蹇呴』鍙戦 WINCH 淇″彿缁欐棫鐨勪富杩涚▼锛岀劧鍚庯紝瀹冪殑宸ヤ綔杩涚▼灏卞皢寮濮嬩粠瀹瑰叧闂細
: PID PPID USER %CPU VSZ WCHAN COMMAND 33126 1 root 0.0 1164 pause nginx: master process /usr/local/nginx/sbin/nginx 33135 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)
涓娈垫椂闂村悗锛屾棫鐨勫伐浣滆繘绋嬪鐞嗕簡鎵鏈夊凡杩炴帴鐨勮姹傚悗閫鍑猴紝灏变粎鐢辨柊鐨勫伐浣滆繘绋嬫潵澶勭悊杈撳叆鐨勮姹備簡锛
: PID PPID USER %CPU VSZ WCHAN COMMAND 33126 1 root 0.0 1164 pause nginx: master process /usr/local/nginx/sbin/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)
杩欐椂锛屽洜涓烘棫鐨勬湇鍔″櫒杩樺皻鏈叧闂畠鐩戝惉鐨勫鎺ュ瓧锛屾墍浠ワ紝閫氳繃涓嬮潰鐨勫嚑姝ワ紝浣犱粛鍙互鎭㈠鏃х殑鏈嶅姟鍣細
- 鍙戦 HUP 淇″彿缁欐棫鐨勪富杩涚▼ - 瀹冨皢鍦ㄤ笉閲嶈浇閰嶇疆鏂囦欢鐨勬儏鍐典笅鍚姩瀹冪殑宸ヤ綔杩涚▼
- 鍙戦 QUIT 淇″彿缁欐柊鐨勪富杩涚▼锛岃姹傚叾浠庡鍏抽棴鍏跺伐浣滆繘绋
- 鍙戦 TERM 淇″彿缁欐柊鐨勪富杩涚▼锛岃揩浣垮叾閫鍑
- 濡傛灉鍥犱负鏌愪簺鍘熷洜鏂扮殑宸ヤ綔杩涚▼涓嶈兘閫鍑猴紝鍚戝叾鍙戦 KILL 淇″彿
鏂扮殑涓昏繘绋嬮鍑哄悗锛屾棫鐨勪富杩涚▼浼氱敱绉婚櫎 .oldbin 鍓嶇紑锛屾仮澶嶄负瀹冪殑 .pid 鏂囦欢锛岃繖鏍凤紝涓鍒囧氨閮芥仮澶嶅埌鍗囩骇涔嬪墠浜嗐
濡傛灉灏濊瘯鍗囩骇鎴愬姛锛岃屼綘涔熷笇鏈涗繚鐣欐柊鐨勬湇鍔″櫒鏃讹紝鍙戦 QUIT 淇″彿缁欐棫鐨勪富杩涚▼浣垮叾閫鍑鸿屽彧鐣欎笅鏂扮殑鏈嶅姟鍣ㄨ繍琛岋細
: 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)