-------------------------------------------------------------------------------------------------------------------------------------

nginx旧

yum -y groupinstall 开发工具
yum -y install pcre , pcre-devel
yum -y install openssl-devel
yum -y install gd-devel.x86_64
useradd nginx -s /sbin/nologin
./configure --prefix=/usr/local/nginx/access.log --http-log-path=/data/logs/nginx/error.log --error-log-path=/data/logs/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_ssl_module --with-http_realip_module --with-http_flv_module --with-http_image_filter_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_stub_status_module && make && make installinstall
mkdir -p /data/logs/nginx #日志路径
主配置文件分离 lnclude server.conf;]

user nginx
worker_processes 1;工作进程数 比cpu少1
新加:worker_cpu_affinity 0001 0010 0100 1000;锁死c4个pu
新加:worker_rlimit_nofile 65535;
pid
错误日志,info级别

http段,协议级别
log_format 日志格式名 日志格式
access_log 文件路径 格式 ;
keepalive_timeout 长连接,0是短链接连接,避免三次握手
gzip no;压缩
gzip_comp_level 压缩级别9最大压缩
负载均衡upstream magedu {
wrr;轮询算法
server 节点ip:端口可以有多个 weight=2级别 健康检测max_fails=1最大1此就失效 fail_timeout=1s; 1秒
server 节点ip:端口可以有多个 weight=1级别 backup;

server段 服务器级别
listen 监听端口,ip:端口 *:端口 default_server; 默认页面
server_name www.magedu.com 同一个ip,同一个端口 通过域名访问,通过dns解析host文件 同一个ip 多个域名

location段 请求级别
(location =)>(location ^路径)>(location~正则)>(location路径)
rewrite 重定向 ^/shop/(.
/.html)$ /tuangou/$1 break备份
老路径 重定向到新路径,$1表示引用(./.html)
last-基本上都用找个flag
break - 中止ewrite,不在继续匹配
redirect - 返回临时重定向的http状态302
permanent - 返回永久重定向的http状态301
proxy_pass http://magedu;
if ($http_user_agent ~ Chrome) [
rewrite ^(.
)$ /chrome/$! break;
]
if ($http_user_agent ~ MSIE) [
rewrite ^(.*)$ /ie/$! break;
]
判断浏览器,进行重定向,提高兼容性,$http_user_agent指定的日志格式,从这里配匹 ~ 正则区分大小写

posted @ 2019-12-05 07:55  给文明以岁月  阅读(106)  评论(0编辑  收藏  举报
----------------------------------------------------------