nginx常用命令

2021-07-28 03:52:08 字數 3611 閱讀 3785

[root@ta30-53 nginx]# pwd

/usr/local/nginx

[root@ta30-53 nginx]# ./sbin/nginx

[root@ta30-53 nginx]# ./sbin/nginx -s stop
[root@ta30-53 nginx]# ./sbin/nginx -s quit

-s都是採用向 nginx 傳送訊號的方式

[root@ta30-53 nginx]# ./sbin/nginx -s reload
上述是採用向 nginx 傳送訊號的方式,或者使用:service nginx reload

[root@ta30-53 nginx]# ./sbin/nginx -c /usr/local/nginx/conf/nginx.conf
-c表示configuration,指定配置檔案

[root@ta30-53 nginx]# ./sbin/nginx -v

nginx version: nginx/1.8.0

[root@ta30-53 nginx]# ./sbin/nginx -v

nginx version: nginx/1.8.0

built by gcc 4.4.7 20120313 (red hat 4.4.7-17) (gcc)

configure arguments:

[root@ta30-53 nginx]# ./sbin/nginx -t     

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok

nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

[root@ta30-53 nginx]# ./sbin/nginx -h

nginx version: nginx/1.8.0

usage: nginx [-?hvvtq] [-s signal] [-c filename] [-p prefix] [-g directives]

options:

-?,-h : this help

-v : show version and exit

-v : show version and configure options then exit

-t : test configuration and exit

-q : suppress non-error messages during configuration testing

-s signal : send signal to a master process: stop, quit, reopen, reload

-p prefix : set prefix path (default: /usr/local/nginx/)

-c filename : set configuration file (default: conf/nginx.conf)

-g directives : set global directives out of configuration file

[root@ta30-53 nginx]# ./sbin/nginx -?

nginx version: nginx/1.8.0

usage: nginx [-?hvvtq] [-s signal] [-c filename] [-p prefix] [-g directives]

options:

-?,-h : this help

-v : show version and exit

-v : show version and configure options then exit

-t : test configuration and exit

-q : suppress non-error messages during configuration testing

-s signal : send signal to a master process: stop, quit, reopen, reload

-p prefix : set prefix path (default: /usr/local/nginx/)

-c filename : set configuration file (default: conf/nginx.conf)

-g directives : set global directives out of configuration file

停止操作

[root@ta30-53 nginx]# ps -ef|grep nginx

root 15208 1 0 14:14 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx

nobody 16563 15208 0 15:34 ? 00:00:00 nginx: worker process

root 17086 16288 0 15:50 pts/0 00:00:00 grep nginx

從容停止nginx

kill -quit 15208

快速停止nginx

kill -term 15208

強制停止nginx

pkill -9 15208

若在nginx.conf配置了pid檔案存放路徑則該檔案存放的就是nginx主程序號,如果沒指定則放在nginx的logs目錄下

kill -訊號型別  '/usr/nginx/logs/nginx.pid'

平滑重啟

如果更改了配置就要重啟nginx,要先關閉nginx再開啟?不是的,可以向nginx 傳送訊號,平滑重啟。

平滑重啟命令

kill -hup 15208

或者使用

nginx -s reload

注意,修改了配置檔案後最好先檢查一下修改過的配置檔案是否正確,以免重啟後nginx出現錯誤影響伺服器穩定執行。判斷nginx配置是否正確命令如下:

nginx -t -c /usr/nginx/conf/nginx.conf 或

nginx -t (推薦) 或

/usr/nginx/sbin/nginx -t

nginx 常用命令

poechant ubuntu sudo sbin nginxpoechant ubuntu sudo sbin nginx s stop poechant ubuntu sudo sbin nginx s quit s都是採用向 nginx 傳送訊號的方式。poechant ubuntu sudo...

Nginx常用命令

usr local nginx sbin nginx t或 usr local nginx sbin t c usr local nginx conf nginx.conf檢測結果會提示配置檔案 出現了錯誤,出現success說明檔案正確。顯示版本資訊可以用 usr local nginx sbin...

nginx常用命令

在nginx.exe目錄,開啟命令列工具,用命令 啟動 關閉 重啟nginx cd 改變工作目錄 start nginx 啟動nginx nginx s stop 強制關閉 nginx s quit 安全關閉 nginx s reload 改變配置檔案的時候,重啟nginx工作程序,來時配置檔案生效...