openresty



下载安装
#wget https://openresty.org/download/ngx_openresty-1.7.10.1.tar.gz
#tar xf ngx_openresty-1.7.10.1.tar.gz
#cd ngx_openresty-1.7.10.1
#./configure --with-luajit
#make && make install

【location】
(1)=/ 和 /
  location = / {
      [configure A]
       }


  location / {
      [configure B]
        }


 #curl  http://localhost/ 匹配B
 分析:本来精确匹配应该为A,但当访问http://localhost/时,默认访问网址为http://localhost/index.html,所以匹配为B


 (2)=/index.html 和 /
  location = /index.html {
      [configure A]
       }


  location / {
      [configure B]
        }
 #curl  http://localhost/ 匹配A


(3)/xixi/ 与 ^~ /xixi/
    location /xixi/ {
      [configure A]
     }


   location ^~ /xixi/ {
      [configure B]
      }


  报错:
  nginx: [emerg] duplicate location "/xixi/" in  /usr/local/openresty/nginx/conf/nginx.conf:58
 分析:/xixi/与^~ /xixi/都属于普通字符匹配,属于重复配置




(4)~ /xixi/ 与 ^~ /xixi/
   location ~ /xixi/ {
      [configure A]
      }
 
  location ^~ /xixi/ {
      [configure B]
     }
  #curl  http://localhost/xixi/  匹配B
 分析:^~ /xixi/优先级大于正则 ~ /xixi/


  #curl  http://localhost/xixi
  报错:404 Not Found
  分析:错误日志显示xixi文件不存在
  # tail -n5 logs/error.log
   2017/02/17 23:19:52 [error] 9732#0: *118 open() "/usr/local/openresty/nginx/html/haha/xixi" failed (2: No such file or directory), client: 127.0.0.1, server: 192.168.204.131, request: "GET /xixi HTTP/1.1", host: "localhost"


 (5)~ /xixi/ 与  /xixi/
   location  /xixi/ {
      [configure A]
      }
 
   location ~ /xixi/ {
      [configure B]
     }   
  #curl  http://localhost/xixi/  匹配B
  分析: ~/xixi/ 优先 /xixi/
 
 
(6)分析错误日志
   2017/02/18 00:05:38 [error] 9987#0: *207 open() "/usr/local/openresty/nginx/html/haha/favicon.ico" failed (2: No such file or directory), client: 192.168.204.1, server: 192.168.204.131, request: "GET /favicon.ico HTTP/1.1", host: "192.168.204.131"
  
 


 
### OpenResty 的使用介绍 OpenResty 是一个基于 Nginx 和 LuaJIT 构建的高性能 Web 平台,它允许开发者构建可扩展的 Web 应用和服务。通过集成多种标准库和第三方模块,OpenResty 提供了一个强大的工具集来处理复杂的业务逻辑。 #### 安装方法概述 对于不同环境下的安装需求,以下是几种常见的安装方式: 1. **源码编译安装** 如果需要完全控制安装过程并自定义配置选项,则可以通过下载官方发布的源码包进行手动编译安装[^2]。 首先确保系统已安装必要的依赖项: ```bash yum install -y pcre-devel openssl-devel gcc --skip-broken ``` 接着获取 OpenResty 源码压缩包,并按照以下步骤操作: ```bash tar -xzvf ngx_openresty-1.15.8.3.tar.gz cd /usr/openresty/openresty-1.15.8.3/ ./configure && make && make install ``` 2. **Yum 软件仓库安装** 对于 CentOS 用户来说,可以利用 Yum 来简化安装流程[^3]。这一步骤涉及添加 OpenResty 的官方软件仓库以及执行简单的安装命令: ```bash yum install -y centos-release-openresty yum install -y openresty ``` 3. **Docker 容器化部署** Docker 提供了一种快速便捷的方式来运行 OpenResty 实例[^4]。只需拉取官方镜像即可完成初始化工作: ```bash docker pull openresty/openresty docker run -itd --name openresty -p 80:80 openresty/openresty ``` #### 基本功能展示 当成功安装完成后,在浏览器中访问服务器地址时,默认会显示一段 HTML 页面内容作为测试用途[^5]。例如: ```html <body> <a href="http://www.example.com">访问Example网站</a> </body> ``` 此页面仅用于验证服务是否正常启动;实际项目开发过程中可以根据具体需求定制响应数据。 --- ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值