大大饭

导航

使用Nginx_01

    Linux中  

      执行yum 时,会报如下错误:出问题

        

 

        

  1. 进入  /etc/yum.repos.d/
  2. 备份  cp CentOS-Base.repo CentOS-Base.repo.old
  3. 编辑    vi CentOS-Base.repo
  4. 代码对应模块修改下
[base]
name=CentOS-$releasever - Base
# mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
# baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
baseurl=https://vault.centos.org/6.10/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

# released updates
[updates]
name=CentOS-$releasever - Updates
# mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
# baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
baseurl=https://vault.centos.org/6.10/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

# additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
# mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
# baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
baseurl=https://vault.centos.org/6.10/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

 5.执行一下
yum clean all 就可以了
 


 

   Nginx主要处理磁盘和网络的 IO

       




vi nginx.conf
  nginx里的配置文件
    http模块比较重要了

    
   
      sendfile:off 需要把文件读到应用程序里内存里,在发送给内核,内核发出去。两次复制操作 性能低
         on 内核直接把文件load上来发给网卡,不用经过应用程序。就一次 (异步网络I/O)

              

 

 

    

    

 

 

 

 

      

location

映射/虚拟目录

location = / {
  [ configuration A ]
}

location / {
  [ configuration B ]
}

location /documents/ {
  [ configuration C ]
}

location ^~ /images/ {
  [ configuration D ]
}

location ~* \.(gif|jpg|jpeg)$ {
  [ configuration E ]
}

location [ = | ~ | ~* | ^~ ] uri { ... }

location URI {} 对当前路径及子路径下的所有对象都生效;

location = URI {} 注意URL最好为具体路径。 精确匹配指定的路径,不包括子路径,因此,只对当前资源生效;

location ~ URI {} location ~* URI {} 模式匹配URI,此处的URI可使用正则表达式,~区分字符大小写,~*不区分字符大小写;

location ^~ URI {} 禁用正则表达式

优先级:= > ^~ > ~|~* > /|/dir/

location配置规则

location 的执行逻辑跟 location 的编辑顺序无关。 矫正:这句话不全对,“普通 location ”的匹配规则是“最大前缀”,因此“普通 location ”的确与 location 编辑顺序无关;

但是“正则 location ”的匹配规则是“顺序匹配,且只要匹配到第一个就停止后面的匹配”;

“普通location ”与“正则 location ”之间的匹配顺序是?先匹配普通 location ,再“考虑”匹配正则 location 。

注意这里的“考虑”是“可能”的意思,也就是说匹配完“普通 location ”后,有的时候需要继续匹配“正则 location ”,有的时候则不需要继续匹配“正则 location ”。两种情况下,不需要继续匹配正则 location :

  • ( 1 )当普通 location 前面指定了“ ^~ ”,特别告诉 Nginx 本条普通 location 一旦匹配上,则不需要继续正则匹配;

  • ( 2 )当普通location 恰好严格匹配上,不是最大前缀匹配,则不再继续匹配正则

 

 

  还是Location

    

 

 

 

 

 

 

 



 

  

 

posted on 2021-05-16 11:54  大大饭  阅读(51)  评论(0)    收藏  举报