• 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

  • 相关阅读:
    TCO 2013 2A
    matlab 中的fmincon参数设定问题
    一步步写自己SqlHelper类库(四):Connection对象
    珠海立方科技实习总结
    Web Services 应用开发学习笔记(三):XML模式定义
    C#笔记(一):类型,泛型,集合
    Web Services 应用开发学习笔记(二):XML文档类型定义
    一步步写自己SqlHelper类库(三):连接字符串
    一步步写自己SqlHelper类库(二):.NET Framework 数据提供程序
    (Joomla)多功能健康模块
  • 原文地址:https://www.cnblogs.com/sfnz/p/4624558.html
Copyright © 2020-2023  润新知