1. 程式人生 > >Nginx日常維護的命令

Nginx日常維護的命令

Nginx是一款輕量級的Web 伺服器/反向代理伺服器及電子郵件(IMAP/POP3)代理伺服器,Nginx的安裝不是很複雜,下面主要講解下日常維護中Nginx常用的一些命令,以下命令都在Nginx的sbin目錄下執行。

1、顯示相關幫助
./nginx -h
nginx version: nginx/1.6.2
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

2、檢測配置檔案

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

3、啟動 Nginx
./nginx

4、過載配置
./nginx -s reload

5、停止 Nginx
./nginx -s stop
./nginx -s quit
stop與quit引數的區別在於stop是快速停止nginx,可能並不儲存相關資訊,quit是完整有序的停止nginx,並儲存相關資訊。

6、指定配置檔案

./nginx -c /usr/local/nginx/conf/nginx.conf

7、 檢視 Nginx 版本
./nignx -v
nginx version: nginx/1.6.2

./nginx -V
nginx version: nginx/1.6.2
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC)
TLS SNI support enabled
configure arguments: --with-http_image_filter_module --with-http_ssl_module --with-http_gzip_static_module