zoukankan      html  css  js  c++  java
  • OpenResty安装与hello world

    安装环境:CentOS 7.0

    1、 安装编译工具、依赖库

    yum -y install readline-devel pcre-devel openssl-devel gcc

    2、 下载openresty-1.13.6.1.tar.gz 源码包,并解压;下载ngx_cache_purge模块,该模块用于清理nginx缓存;下载nginx_upstream_check_module模块,该模块用于ustream健康检查

    wget https://openresty.org/download/openresty-1.13.6.1.tar.gz
    tar -zxvf openresty-1.13.6.1.tar.gz
    cd openresty-1.13.6.1/bundle
    wget http://labs.frickle.com/files/ngx_cache_purge-2.3.tar.gz
    tar -zxvf ngx_cache_purge-2.3.tar.gz
    wget https://github.com/yaoweibin/nginx_upstream_check_module/archive/v0.3.0.tar.gz
    tar -zxvf v0.3.0.tar.gz

    3、配置需安装的模块

    ./configure --prefix=/usr/local/openresty --with-luajit --with-http_ssl_module --user=root --group=root --with-http_realip_module --add-module=./bundle/ngx_cache_purge-2.3/ --add-module=./bundle/nginx_upstream_check_module-0.3.0/

    4、编译安装

    make -j2 && make install

    5、编写nginx配置文件

    cd /usr/local/openresty/nginx/conf/
    vim nginx.conf

    添加这一段

       location /hello {
                default_type text/html;
                content_by_lua '
                    ngx.say("<p>hello, world</p>")
                ';
            }

    然后测一下

    [root@VM_0_10_centos conf]# curl 127.0.0.1/hello
    <p>hello, world</p>

    6、还有另一种方式,使用lua文件

    继续编写nginx配置文件

         

    location /hello {
      content_by_lua_file /usr/local/openresty/nginx/conf/lua/hello.lua;
    }

    编写hello.lua文件

    ngx.say('<p>hello world!</p>')

    检查语法

    ./nginx -t -c /usr/local/openresty/nginx/conf/nginx.conf

    重启nginx

    ./nginx -s reload -c /usr/local/openresty/nginx/conf/nginx.conf

    测试一下

    [root@VM_0_10_centos conf]# curl 127.0.0.1/hello                               
    <p>hello world!</p>

    成功输出了hello world!

  • 相关阅读:
    Vue数据绑定和响应式原理
    JavaScript实现MVVM之我就是想监测一个普通对象的变化
    缓存的理解
    理解promise 02
    线段与线段的交点
    线段与线段交点的推导公式
    promise你懂了吗?
    wx import require的理解
    webgl example1
    sublime2常用插件
  • 原文地址:https://www.cnblogs.com/tangzhe/p/9563095.html
Copyright © 2011-2022 走看看