FAQ

Page Discussion Edit History

ChsCommandLine

(Redirected from NginxChsCommandLine)

Nginx涓枃鏂囨。 > 杩愯鍜屾帶鍒 Nginx - 鍛戒护琛屽弬鏁板拰淇″彿

涓嶅儚璁稿鍏朵粬杞欢绯荤粺锛孨ginx 浠呮湁鏁颁釜鍛戒护琛屽弬鏁帮紝瀹屽叏閫氳繃閰嶇疆鏂囦欢鏉ラ厤缃紙鎯宠薄涓涓嬶級銆

  • [#options 閫夐」]
  • [#example 绀轰緥]
  • [#lncus 浣跨敤淇″彿鍔犺浇鏂扮殑閰嶇疆]
  • [#utnbotf 骞虫粦鍗囩骇鍒版柊鐨勪簩杩涘埗浠g爜]

Template:Anchor

Contents

[edit] 閫夐」

-c </path/to/config> 涓 Nginx 鎸囧畾涓涓厤缃枃浠讹紝鏉ヤ唬鏇跨己鐪佺殑銆

-t 涓嶈繍琛岋紝鑰屼粎浠呮祴璇曢厤缃枃浠躲俷ginx 灏嗘鏌ラ厤缃枃浠剁殑璇硶鐨勬纭э紝骞跺皾璇曟墦寮閰嶇疆鏂囦欢涓墍寮曠敤鍒扮殑鏂囦欢銆

-v 鏄剧ず nginx 鐨勭増鏈

-V 鏄剧ず nginx 鐨勭増鏈紝缂栬瘧鍣ㄧ増鏈拰閰嶇疆鍙傛暟銆

Template:Anchor

[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 閲嶆柊鎵撳紑鏃ュ織鏂囦欢

Template:Anchor

[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)

Template:Anchor

[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)


[edit] 鍙傝

鍛戒护琛岄夐」

淇″彿