1 编译环境
yum -y groupinstall "Development Tools" "Server Platform Development"
2 必要
yum -y install openssl-devel zlib-devel pcre-devel pcre openssl
3 编译参数
./configure \
--prefix=/usr/local/nginx \
--sbin-path=/usr/sbin/nginx \
--user=nginx \
--group=nginx \
--conf-path=/etc/nginx/nginx.conf \
--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/lock/nginx.lock \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_stub_status_module \
--with-http_gzip_static_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/fcgi/ \
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
--http-scgi-temp-path=/var/tmp/nginx/scgi \
--with-debug \
--with-pcre | tee /tmp/nginx.out
#make && make install
注意:添加模块只需要 执行config 和make(不执行makeinstall)然后
#mv /usr/sbin/nginx /usr/sbin/nginx.bak
#cp ./objs/nginx /usr/sbin/nginx
4 配置
(1)主配置文件:nginx.conf
include conf.d/*.conf
/etc/nginx/conf.d/*.conf
mime.types
(2)fastcgi的配置文件:
fastcgi.conf
fastcgi_params
uwsgi_params
(3)配置指令(以分号结尾):
支持使用变量:
内置变量:由模块引入;
自定义: set variable value;
引用变量:$variable
(4)配置文件结构
mail block
event {
......
}
http {
......
}
5 配置详解
http配置段
http {
server {
root
server_name
alias
location /usr/ {
}
}
}
Nginx基本核心配置的类别
用于调试、定位问题
正常运行的必备配置
优化性能的配置
事件类的配置
worker进程应该以普通用户身份运行。nginx用户,nginx组
http的方法:GET,HEAD,POST,PUT,DELETE OPTIONS TRACE-