介绍
针对Nginx
中常用的命令进行介绍。
以下命令都是在nginx/sbin
目录下进行。
命令
启用nginx
$ ./nginx
停用Nginx
# 快速停止nginx,即使当前nginx处于工作中,也会立即停止
$ ./nginx -s stop
# 延时停止nginx,只有当前nginx出于空闲状态中,才会停止,这种方式和上一种比起来更为优雅,推荐使用
$ ./nginx -s quit
检查nginx.conf
# 用于检查nginx.conf文件语法是否正确
$ ./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
重新加载nginx.conf
# 在不用关闭启动的情况下,加载nginx.conf配置文件并立刻起效
$ ./nginx -s reload
查看nginx版本
$ ./nginx -v
nginx version: nginx/1.17.9
查看nginx详细信息
# 展示信息如下:
# 版本信息
# 依赖环境(gcc、openssl等)
# 是否开启了TNS SNI SUPPORT,该功能表明nginx是否开启了多个SSL证书支持
# 进行configure的参数
$ ./nginx -V
nginx version: nginx/1.17.9
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/run/nginx/nginx.lock --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-http_gzip_static_module --http-client-body-temp-path=/var/temp/nginx/client --http-proxy-temp-path=/var/temp/nginx/proxy --http-fastcgi-temp-path=/var/temp/nginx/fastcgi --http-uwsgi-temp-path=/var/temp/nginx/uwcgi --http-scgi-temp-path=/var/temp/nginx/scgi --with-http_ssl_module
命令使用帮助
$ ./nginx -h
nginx version: nginx/1.17.9
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