您的位置:首页 > 运维架构 > Nginx

nginx常用命令

2016-04-07 00:00 441 查看
摘要: 权当快速查阅了。

-1、官方文档
http://nginx.org/en/docs/switches.html
0、查看官方提醒

./sbin/nginx -h

结果如下
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

1、启动nginx

./sbin/nginx

2、检查nginx配置是否合法

./sbin/nginx -t
#需要详情
./sbin/nginx -t -c [配置文件地址]

3、关闭或停止nginx

./sbin/nginx -s stop
./sbin/nginx -s quit

4、使用kill关闭或停止nginx

停止操作是通过向nginx进程发送信号(什么是信号请参阅linux文 章)来进行的
步骤1:查询nginx主进程号
ps -ef | grep nginx
在进程列表里 面找master进程,它的编号就是主进程号了。
步骤2:发送信号
从容停止Nginx:(请求处理完再关闭)
kill -QUIT 主进程号
快速停止Nginx:
kill -TERM 主进程号
强制停止Nginx:
kill -9 nginx

5、重新加载nginx配置文件

./sbin/nginx -s reload
从容更新配置文件
kill -HUP pid

6、指定nginx配置文件

./sbin/nginx -c /usr/local/nginx/conf/nginx.conf

7、查看nginx版本

./sbin/nginx -v
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  nginx