Nginx的常用命令

2021-10-23 09:20:39 字數 1725 閱讀 9817

vi編輯開啟/etc/profile檔案,在檔案末尾加入以下**

export nginx_home=/usr/local/nginx

export path=$path:$nginx_home/sbin

執行 source /etc/profile ,使配置檔案生效。此時nginx可在終端直接使用

$ nginx ...
$ whereis nginx

nginx: /usr/local/nginx

可以看到nginx預設安裝路徑在/usr/local/nginx,此時使用nginx命令方法:

$ /usr/local/nginx/sbin/nginx  ...
$ /usr/local/nginx/sbin/nginx -h

nginx version: nginx/1.16.1

usage: nginx [-?hvvttq] [-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

-t : test configuration, dump it 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

啟動nginx:

方式一:直接啟動,會找預設配置檔案,路徑:conf/nginx.conf

$ /usr/local/nginx/sbin/nginx
方式二:選擇指定配置啟動

$ /usr/local/nginx/sbin/nginx  -c /etc/nginx/nginx.conf
平滑更新配置
$ /usr/local/nginx/sbin/nginx  -s reload
停止

方式一:-s引數停止

/usr/local/nginx/sbin/nginx  -s stop
方式二:殺死nginx主程序

$ ps -ef |

grep nginx # 找到nginx的主程序

$ kill -9 主程序號

nginx常用命令

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 常用命令

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...