事件驱动:epoll(边缘触发,Linux) kqueue(BSD)
I/O复用器:select,poll,rt signal
支持sendfile、sendfile64
支持AIO
支持mmap内存映射
nginx的工作模式:非阻塞、事件驱动,由一个master进程生成多个worker进程,每个worker响应n个请求。
6.模块类型:
核心模块、Standard HTTP modules、Optional HTTP modules、Mail modules、第三方模块
7.源码安装
yum -y install gcc gcc-c++
yum -y install pcre pcre-devel
yum -y install zlib zlib-devel
yum -y install openssl openssl-devel
tar xf nginx-VERSION.tar
cd nginx-VERSION
groupadd -r nginx
useradd -r nginx -g nginx
./configure --help(获取帮助)
--with-xx:原本没有启动,启动起来;--without-xx:原本已启动,停止启动
./configure --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/conf/nginx/nginx.conf --user=nginx --group=nginx --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/log/nginx.lock --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_flv_module --with-http_mp4_module --http-client-body-temp-path=/var/tmp/nginx/client --http-proxy-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi
make -j 4 && make install
mkdir -pv /var/tmp/nginx/{client,proxy,fastcgi,uwsgi}
启动nginx
/usr/local/nginx/sbin/nginx
8.配置文件介绍
main配置段:全局配置段
event{}:定义event模型工作特性
http{}:定义http协议相关的配置
配置指令:要以分号结尾。
支持使用变量:
内置变量:模块会提供内置变量定义
自定义变量:set var_name value;
主配置段的指令:
正常运行必备的配置
1.user username [groupname];指定运行worker进程的用户和组;
2.pid /path/to/pid_file;指定nginx守护进程的pid文件
pid /var/run/nginx/nginx.pid
3.worker_rlimit_nofile number;指定所有worker进程所能打开最大文件句柄数
优化性能的配置
1.worker_processes #;worker进程的个数;通常应该略少于CPU物理核心数;支持auto








