Nginx基本命令

1、Nginx帮助命令

nginx -h

[root@VM_0_2_centos sbin]# ./nginx -h

#nginx版本号
nginx version: nginx/1.15.12

#使用方法
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 #使用信号控制Nginx进程停止、放弃、重启、重新读取配置
  -p prefix     : set prefix path (default: /data/software/nginx/) #设备Nginx的存放路径
  -c filename   : set configuration file (default: conf/nginx.conf) #读取配置参数路径
  -g directives : set global directives out of configuration file #指定附加配置的路径

2、Nginx启动命令

nginx

[root@VM_0_2_centos sbin]# ./nginx
[root@VM_0_2_centos sbin]# ps -ef | grep nginx
root     20731     1  0 10:50 ?        00:00:00 nginx: master process ./nginx
nobody   20732 20731  0 10:50 ?        00:00:00 nginx: worker process

3、Nginx停止命令

nginx -s stop

[root@VM_0_2_centos sbin]# ./nginx -s stop
[root@VM_0_2_centos sbin]# ps -ef | grep nginx
root     20917 16297  0 10:51 pts/1    00:00:00 grep --color=auto nginx

4、Nginx重启

nginx -s reopen # Nginx进程之前必须存在 该过master进程和work进程不变

[root@VM_0_2_centos sbin]# ./nginx -s reopen
[root@VM_0_2_centos sbin]# ps -ef | grep nginx
root     21218     1  0 10:53 ?        00:00:00 nginx: master process ./nginx
nobody   21219 21218  0 10:53 ?        00:00:00 nginx: worker process

5、重新加载配置文件

nginx -s reload # Nginx进程之前必须存在,该过程master进程不变,但是work进程会重启

[root@VM_0_2_centos sbin]# ./nginx -s reload
[root@VM_0_2_centos sbin]# ps -ef | grep nginx
root     21218     1  0 10:53 ?        00:00:00 nginx: master process ./nginx
nobody   25522 21218  0 11:16 ?        00:00:00 nginx: worker process

6、指定配置文件

nginx -c /conf/nginx.conf

[root@VM_0_2_centos sbin]# ./nginx -c /data/software/nginx/conf/nginx.conf
[root@VM_0_2_centos sbin]# ps -ef | grep nginx
root     28787     1  0 11:33 ?        00:00:00 nginx: master process ./nginx -c /data/software/nginx/conf/nginx.conf
nobody   28788 28787  0 11:33 ?        00:00:00 nginx: worker process
root     28801 16297  0 11:33 pts/1    00:00:00 grep --color=auto nginx

7、测试配置文件正确性

nginx -t

[root@VM_0_2_centos sbin]# ./nginx -t
#表示配置文件ok,如果错误会输入文件哪一行错误
nginx: the configuration file /data/software/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /data/software/nginx/conf/nginx.conf test is successful

你可能感兴趣的:(Nginx,nginx,centos,linux)