[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

最新文章

  1. 学习计划-----java初级工程师
  2. VS2015中GLAUX库的链接问题
  3. UML类图中的六种关系及实例
  4. php基础语句2
  5. ubuntu QWT Qt
  6. UML从需求到实现----用例
  7. NOI2014 全国互测Round2
  8. 命令行创建AVD
  9. 【HTML】Advanced3:Tables: Columns, Headers, and Footers
  10. 使用MyEclipse实现简单的Servlet程序
  11. Codeforces Round #272 (Div. 1) Problem C. Dreamoon and Strings
  12. Flash型单片机的加密与解密
  13. vs2013调试的时候卡顿
  14. abstract和interface
  15. 定义 : angular view 和controller 之前的 ng-init 由谁来负责
  16. Eclipse开发C/C++ 安装配置
  17. 2018-2019-2 《网络对抗技术》Exp4 恶意代码分析 Week6 20165311
  18. Python数据结构之单链表
  19. 基于axios创建的实例使用axios.all,报错:this.$http is not a function,但请求成功
  20. 7-qt随机数qrand

热门文章

  1. 【bzoj4240】有趣的家庭菜园
  2. Eclipse中设置编码的方法
  3. Java客户端:调用EyeKey HTTP接口进行人脸对比
  4. Zookeeper原理和应用
  5. 关于android的DB操作
  6. 利用JS判断当前来路域名并跳转到指定页面
  7. 关于苹果iPhone手机对页面margin属性无效的解决方法一(如有错误,请留言批评)
  8. 软件GUI测试中的关注点
  9. zoj 1109 Language of FatMouse 解题报告
  10. hdu 4463 Outlets(最小生成树)