Nginx学习笔记(二)

一、Nginx配置文件的通用语法

1.配置文件由指令与指令块组成

2.每条指令以;分号结尾,指令与参数间用空格符号分隔

3.指令块以{}大括号将多条指令组织在一起

4.include语句允许组合多个配置文件以提升可维护性

5.使用#添加注释

6.使用$符号使用变量

7.部分指令的参数支持正则表达式

二、Nginx命令行

格式:nginx -s reload

帮助:-?-h

使用指定的配置文件 -c

指定配置指令 -g

指定运行目录-p

发送信号 -s

  立刻停止服务 stop

  优雅的停止服务 quit

  重载配置文件 reload

  重新开始记录日志文件reopen

测试配置文件是否有语法错误 -t -T

打印nginx的版本信息,编译信息-v -V

命令行演示:

# 测试nginx文件正确性
[root@localhost ~]# /home/geek/nginx/sbin/nginx -t -c /home/geek/nginx/conf/nginx.conf
nginx: the configuration file /home/geek/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /home/geek/nginx/conf/nginx.conf test is successful
#查看nginx进程
[root@localhost ~]# ps -ef | grep nginx
root      50577      1  0 08:25 ?        00:00:00 nginx: master process /home/geek/nginx/sbin/nginx
nobody    50578  50577  0 08:25 ?        00:00:00 nginx: worker process
root      50582  45974  0 08:26 pts/0    00:00:00 grep --color=auto nginx

 [root@localhost nginx]# vim conf/nginx.conf

#重新加载配置
[root@localhost ~]# cd /home/geek/nginx/sbin
[root@localhost sbin]# ./nginx -s reload
原文地址:https://www.cnblogs.com/lxcy/p/10039733.html