[root@webmaster nginx]# ./sbin/nginx -h
nginx version: nginx/1.12.2
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: /app/nginx-1.12.2/)
-c filename : set configuration file (default: conf/nginx.conf)
-g directives : set global directives out of configuration file

  

检查版本与配置项

  -v            : show version and exit
-V : show version and configure options then exit
[root@nginx2 nginx]# ./sbin/nginx -V
nginx version: nginx/1.12.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-pcre=/tmp/pcre-8.41/

指定配置文件启动

-c filename   : set configuration file (default: conf/nginx.conf)
[root@nginx2 nginx]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

[root@nginx2 nginx]# ps aux| grep nginx
avahi 725 0.0 0.0 30196 452 ? Ss Jun19 0:03 avahi-daemon: running [nginx2.local]
root 94817 0.0 0.1 45968 1132 ? Ss 22:07 0:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

检查conf语法是否正确

 -t            : test configuration and exit
-c filename : set configuration file (default: conf/nginx.conf)
[root@nginx2 ~]# /usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
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

平滑重启,重读conf

如果修改./nginx/conf/nginx.conf,nginx不重启不会重新加载新的conf。例如:我修改默认的location / ,把ab.html放在第一访问序列。不重启,则仍是访问index.html

location / {
root html;
index ab.html index.html index.htm;
}

然后用-s reload平滑重启nginx,这样就会加载新的配置文件。再访问ip,就会显示ab.html。

[root@webmaster nginx]# ./sbin/nginx -s reload

  

重读日志

nginx运行时打开访问日志文件,如果我用mv给这个文件改名,由于文件特性,是没有用的。nginx还是根据文件描述符打开那个文件,往里面写日志。

这样就无法进行日志分割。

[root@nginx2 logs]# lsof| grep nginx| grep log
nginx 45792 root 2w REG 253,0 4862 33683908 /usr/local/nginx/logs/error.log
nginx 45792 root 8w REG 253,0 17896102 33683910 /usr/local/nginx/logs/nginx_access.log
nginx 45792 root 9w REG 253,0 4862 33683908 /usr/local/nginx/logs/error.log

-s reopen就是使nginx重读日志文件。

[root@webmaster nginx]# ./sbin/nginx -s reopen

这时发现,nginx新创建了一个access.log文件,并往里面写日志。

[root@nginx2 logs]# ll
total 17500
-rw-r--r--. 1 www root 333 Jun 21 21:53 access.log
-rw-r--r--. 1 www root 666 Jun 21 21:52 access.log.xx

nginx命令介绍的更多相关文章

  1. nginx命令:启动,停止及命令参数详解

    nginx命令:启动nginx 在Windows上安装好nginx后,我们需要启动nginx服务,启动nginx服务的命令行操作主要有两种方式,即 1 C:/nginx-0.8.53>nginx ...

  2. nginx命令和配置

    centos 6.8安装的nginx 1.12.2 1.nginx常用的命令 使用nginx命令前,进入到/usr/local/nginx/sbin/目录 1)查看nginx版本 进入到/usr/lo ...

  3. Nginx-->基础-->理论-->002:Nginx进程介绍

    一.Nginx进程介绍

  4. Nginx-->基础-->理论-->001:Nginx基本介绍

    一.nginx基本介绍 传统上基于进程或者线程模型架构的web服务通过每进程或者每线程处理并发连接请求,这势必毁在网络和I/O操作时产生阻塞,其另外一个必然结果则是对内存和CPU的利用率低下,产生一个 ...

  5. 12个Linux进程管理命令介绍(转)

    12个Linux进程管理命令介绍 [日期:2015-06-02] 来源:Linux中国  作者:Linux [字体:大 中 小]   执行中的程序在称作进程.当程序以可执行文件存放在存储中,并且运行的 ...

  6. 2.SDK目录结构和adb工具及命令介绍

    安卓开发学习笔记 1.安卓开发之环境搭建 2.SDK目录结构和adb工具及命令介绍 1.SDK目录介绍: ******************************** add-ons:Androi ...

  7. git各种命令介绍以及碰到的各种坑

    一.各种命令介绍: git pull:从其他的版本库(既可以是远程的也可以是本地的)将代码更新到本地,例如:'git pull origin master'就是将origin这个版本库的代码更新到本地 ...

  8. nginx 命令

    nginx 命令 sudo /etc/init.d/nginx configtest     测试是否配置有错 sudo /usr/local/nginx/sbin/nginx -s reload   ...

  9. tar.xz如何解压:linux和windows下tar.xz解压命令介绍

    在linux下怎么解压和压缩tar.xz文件? (本文由www.169it.com搜集整理) 在linux下解压tar.xz文件步骤 1 2 # xz -d ***.tar.xz  //先解压xz # ...

随机推荐

  1. 光纤与PON基础概念整理

    近期有幸接触到通讯这一领域,此文专门用于整理记录. 首先是光纤与光缆  光纤(OpticalFiber,OF)是用来导光的透明介质纤维,一根有用化的光纤是由多层透明介质构成,一般能够分为三部分:折射率 ...

  2. BoW(SIFT/SURF/...)+SVM/KNN的OpenCV 实现

    本文转载了文章(沈阳的博客),目的在于记录自己重复过程中遇到的问题,和更多的人分享讨论. 程序包:猛戳我 物体分类 物体分类是计算机视觉中一个很有意思的问题,有一些已经归类好的图片作为输入,对一些未知 ...

  3. 64位CentOs7源码安装mysql-5.6.35过程分享

    首先安装依赖包,避免在安装过程中出现问题 [root@bogon liuzhen]# yum -y install gcc gcc-c++[root@bogon liuzhen]# yum -y in ...

  4. (转载)js(jquery)的on绑定点击事件执行两次的解决办法

    js(jquery)的on绑定点击事件执行两次的解决办法—不是事件绑定而是事件冒泡 遇到的问题:jquery中用.on()给页面中新加的元素添加点击事件时,点击事件源,绑定的事件执行两次,这里的ale ...

  5. 正则表达式pattern的匹配格式

    0> 匹配 -------------------------------------------------------------------------------- (pattern)  ...

  6. Velocity模板引擎笔记

    模板引擎中判断对象是否为空: #if(!${jsonObj.data.buyerName} || ${jsonObj.data.buyerName} == '')         <p>采 ...

  7. 解决ubuntu10.04不能上网

    1:命令行输入:lspci查看驱动,最后几行如果有ethernet controller:atheros communications ar8151 v1.0*的话,就说明驱动没有安装好, 2:下载地 ...

  8. xalion三层与Web开发帖子一览表 good

    使用http.sys,让delphi 的多层服务飞起来(Delphi借用http.sys充当http服务器,也就可以发送返回JSON等信息,当然浏览器也可以使用)http://www.cnblogs. ...

  9. ADB结构及代码分析【转】

    本文转载自:http://blog.csdn.net/happylifer/article/details/7682563 最近因为需要,看了下adb的源代码,感觉这个作者很牛,设计的很好,于是稍微做 ...

  10. android user 版本如何默认adb调试为打开【转】

    本文转载自:http://blog.csdn.net/chaihuasong/article/details/50342119 A. 软件准备 user版本需要先打开USB debug开关,打开方式如 ...