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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值