启动Nginx
进入sbin目录。
./nginx
关闭Nginx
进入sbin目录。
- 暴力关闭(不推荐的方式)
./nginx -s stop
用户和服务器在进行通信时,如果直接就关闭,所有正在请求服务器的连接都会被关闭。
- 更好的关闭方式(推荐的方式)
./nginx -s quit
- 如果没有客户端请求服务器,就会直接关闭nginx;
- 如果有客户端和服务器正在发生通信时,会维持连接,当关闭连接后,确认没有连接正在进行,才会关闭nginx。
注:quit只针对http请求,如果不是,就不适用。
查看Nginx的版本信息
进入sbin目录。
1.版本信息(简单)
./nginx -v

2.具体信息
./nginx -V

- nginx version:nginx的版本信息;
- built by:编译的环境;
- configure arguments:配置的环境变量。
获取Nginx的帮助信息
进入sbin目录。
./nginx -?
./nginx -h

帮助信息
-?,-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的核心配置文件
./nginx -s reload
一般会搭配到检查nginx.conf配置文件的指令一起使用。
检测nginx.conf配置文件语法是否正确
进入sbin目录。
./nginx -t

重新指定一个nginx.conf文件
./nginx -c /usr/local/nginx/conf/nginx.conf
查看Nginx的进程信息
ps -ef|grep nginx

