【Nginx】nginx日常命令

看下nginx命令的帮助信息

[root@localhost oa_workflow_test]# /usr/local/nginx/sbin/nginx -h
nginx version: nginx/1.12.0
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版本

[root@localhost ~]# nginx -v (注意是小v)
nginx version: nginx/1.12.0

查看nginx安装了哪些模块

[root@localhost ~]# nginx -V(注意是大V)
nginx version: nginx/1.12.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --user=www --group=www --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-threads

可以格式化后显示

[root@localhost ~]# nginx -V 2>&1 | sed "s/\s\+--/\n --/g"
nginx version: nginx/1.12.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments:
 --user=www
 --group=www
 --prefix=/usr/local/nginx
 --with-http_ssl_module
 --with-http_stub_status_module
 --with-threads

重读nginx配置文件

[root@localhost conf]# /usr/local/nginx/sbin/nginx -s reopen

 检查配置文件是否正确

 -t 参数 ,不运行nginx,而仅仅测试配置文件。nginx 将检查配置文件的语法的正确性,并尝试打开配置文件中所引用到的文件。

[root@localhost conf]# /usr/local/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@oa-dev conf]# /opt/app/nginx/sbin/nginx -t -c /opt/app/nginx/conf/nginx.conf
nginx: [warn] "ssl_stapling" ignored, issuer certificate not found for certificate "/opt/app/nginx/conf/ssl/server2018.crt"
nginx: the configuration file /opt/app/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /opt/app/nginx/conf/nginx.conf test is successful

查看nginx进程信息

[root@oa-dev conf]# ps -ef|grep nginx
root       961     1  0 04:24 ?        00:00:00 nginx: master process /opt/app/nginx/sbin/nginx
nobody     970   961  0 04:24 ?        00:00:00 nginx: worker process
nobody     971   961  0 04:24 ?        00:00:00 nginx: worker process

 

nginx -h 查看帮助信息
nginx -v 查看Nginx的版本号
nginx -V 显示Nginx的版本号和编译信息
start nginx 启动Nginx
nginx -s stop 快速停止和关闭Nginx
nginx -s quit 正常停止或关闭Nginx
nginx -s reload 配置文件修改重新加载
nginx -t 测试Nginx配置文件的正确性及配置文件的详细信息 

 

posted @ 2018-06-01 01:12  songguojun  阅读(262)  评论(0编辑  收藏  举报