zoukankan      html  css  js  c++  java
  • Nginx *基本框架

    全局配置指令:
    user nginx;

    模块配置段
    # 事件驱动模块,提供并发响应功能
    events{
    ......
    }
    # http模块,提供web请求处理,可嵌套其他重要模块
    http{
    .......#server{}
    }

    开始配置:#备份nginx.conf ,清空文件
    # vim /etc/hosts 增加主机记录
    vim /etc/nginx/nginx.conf

    worker_processes 2; # 两个nginx进程
    events {
    worker_connections 1024; # 可同时处理1024个http请求
    }

    http {
    include mime.types; #调用mime ,可以处理多媒体
    default_type application/octet-stream;

    upstream test {
    # ip_hash; # 基于客户端的hash值进行请求分配
    server test1.com weight=10; # 权重负载
    server test2.com weight=20;
    }

    server {
    listen 80;
    server_name afan.com; # 用户输入网页先匹配到server{}中
    location / {
    proxy_pass http://test/index.html; # 扔给后端服务器,
    # html 是upstream的引用,先扔给 upstream html{}模块
    }
    }

    #############################################3
    server { #nginx至少有个虚拟主机才能工作
    listen 80;
    server_name Localhost; # 虚拟主机名称
    access_log /var/log/nginx/access_html.log html_log; #若localtion中,优先
    root html; # 网站主目录 ,一般是配置文件所在的目录

    location{}

    }
    }

    # 压力测试:# while true; do curl afan.com;done
    # shell : for i in `seq 1 20` ;do
    curl afan.com
    sleep 0.5
    done

  • 相关阅读:
    [HAOI2011] 向量
    [HNOI2004] 树的计数
    [TJOI2009] 猜数字
    Wannafly Camp 2020 Day 6K 最大权值排列
    [HAOI2012] 容易题
    [ZJOI2008] 生日聚会
    [CQOI2007] 余数求和
    [CQOI2009] 中位数
    [SDOI2012] Longge的问题
    我的Apache又挂了之apache错误:server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName'
  • 原文地址:https://www.cnblogs.com/wanzf/p/10654099.html
Copyright © 2011-2022 走看看