• nginx+lua安装配置


    1.选定源码目录
    选定目录 /usr/local/

    cd /usr/local/

    2.安装PCRE库
    cd /usr/local/
    wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.21.tar.gz
    tar -zxvf pcre-8.21.tar.gz
    cd pcre-8.21
    ./configure --prefix=/usr/local/pcre
    make
    make install


    3.安装zlib库
    cd /usr/local/
    wget http://zlib.net/zlib-1.2.8.tar.gz
    tar -zxvf zlib-1.2.8.tar.gz cd zlib-1.2.8
    ./configure --prefix = /usr/local/zlib
    make
    make install

    4.安装openssl

    cd /usr/local/
    wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
    tar -zxvf openssl-1.0.1c.tar.gz
    ./config --prefix = /usr/local/openssl
    make
    make install


    5.下载编译LuaJIT
    wget -c http://luajit.org/download/LuaJIT-2.0.2.tar.gz
    tar xzvf LuaJIT-2.0.2.tar.gz
    cd LuaJIT-2.0.2
    make install PREFIX=/usr/local/luajit
    echo "/usr/local/luajit/lib" > /etc/ld.so.conf.d/usr_local_luajit_lib.conf
    ldconfig
    #注意环境变量!
    export LUAJIT_LIB=/usr/local/luajit/lib
    export LUAJIT_INC=/usr/local/luajit/include/luajit-2.0

    6.下载并解压ngx_devel_kit、lua-nginx-module、echo-nginx-module
    wget -c https://github.com/simpl/ngx_devel_kit/archive/v0.2.18.tar.gz
    wget -c https://github.com/chaoslawful/lua-nginx-module/archive/v0.9.15.tar.gz
    wget https://github.com/agentzh/echo-nginx-module/tarball/master -O echo-nginx-module.tar.gz
    tar xzvf lua-nginx-module-0.9.15.tar.gz
    tar xzvf echo-nginx-module.tar.gz
    tar zxvf simpl-ngx_devel_kit.tar.gz


    7.编译安装nginx
    wget -c http://nginx.org/download/nginx-1.8.0.tar.gz
    tar -zxvf nginx-1.8.0.tar.gz
    cd ginx-1.8.0

    ./configure --with-http_gzip_static_module --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --prefix=/usr/local/nginx --with-pcre=/usr/local/pcre-8.32 --with-zlib=/usr/local/zlib-1.2.8 --with-openssl=/usr/local/openssl-1.0.1c --add-module=/usr/local/simpl-ngx_devel_kit-b62f5a3 --add-module=/usr/local/lua-nginx-module-0.9.15 --add-module=/usr/local/openresty-echo-nginx-module-7bc71d2

    make && make install

    8. 检测版本

    自己编译官方的 nginx 源码包,只需事前指定 LUAJIT_INC 和 LUAJIT_LIB 这两个环境变量。
    验证你的 LuaJIT 是否生效,可以通过下面这个接口:

    location = /lua-version {
    content_by_lua '
    if jit then
    ngx.say(jit.version)
    else
    ngx.say(_VERSION)
    end
    ';
    }

    9.Hello,World
    在nginx.conf中的service添加一个location。

    location = /test {
    content_by_lua '
    ngx.say("Hello World")
    ngx.log(ngx.ERR, "err err err")
    ';
    }

    用户访问 http://localhost/test 将会打印出“Hello World”内容。


    参考文章:
    http://www.ttlsa.com/nginx/nginx-lua/
    http://www.cnblogs.com/zhuhongbao/archive/2013/06/04/3118061.html
    http://tengine.taobao.org/book/
    http://wiki.nginx.org/HttpLuaModule

  • 相关阅读:
    漫谈计算机组成原理(九)定点数及定点数的运算
    漫谈计算机组成原理(八)原码、补码、反码
    漫谈计算机组成原理(七)I/O系统
    漫谈计算机组成原理(六)数据校验方法
    漫谈计算机组成原理(五)高速缓冲存储器
    漫谈计算机组成原理(四)主存
    致计算机专业准大一新生
    购物车原理以及实现
    Ajax发送PUT/DELETE请求时出现错误的原因及解决方案
    浅谈乱码原因及解决方案
  • 原文地址:https://www.cnblogs.com/sfnz/p/4624558.html
Copyright © 2020-2023  润新知