01.nginx简介
[toc]{type: “ol”, level: [2, 3, 4, 5]}
工作原理
启动后生成一个主进程,根据配置文件的选项来生成子进程/工作进程
主进程负责转发用户的请求,不负责处理用户的请求
工作进程的个数,一般为CPU核心数-1或-2
安装
wget https://nginx.org/download/nginx-1.16.1.tar.gz
tar xf nginx-1.16.1.tar.gz
cd nginx-1.16.1
yum install gcc zlib2-devel pcre-devel openssl-devel ./configure --prefix=/opt/nginx --with-http_ssl_module --with-http_stub_status_module
make && make install
目录结构
[root@localhost nginx]
conf html logs sbin
conf 配置文件
html 存放静态文件 index.html 是默认的欢迎页面
logs 日志目录
sbin 二进制文件
# 启动以后会生成一个主进程,根据配置文件的选项来生成子进程(工作进程),主进程不负责处理用户的请求,用来转发用户的请求,真正负责处理用户请求的是子进程
命令格式
./sbin/nginx -h
nginx version: nginx/1.16.1
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: /opt/nginx/)
-c filename : set configuration file (default: conf/nginx.conf)
-g directives : set global directives out of configuration file