nginx1.4.6调用lua

系统环境: ubuntu14.04 nginx1.4.6

1.安装依赖包

apt-get -y install lua5.1 libreadline-dev libncurses5-dev libpcre3-dev\
  libssl-dev perl make build-essential curl libxml2 libxslt1-dev \
  libgd-dev libgeoip-dev

2.安装luajit

    cd /usr/local/src

    wget http://luajit.org/download/LuaJIT-2.1.0-beta2.tar.gz
    tar zxf LuaJIT-2.1.0-beta2.tar.gz

    cd LuaJIT-2.1.0-beta2

    make PREFIX=/usr/local/luajit
    make install PREFIX=/usr/local/luajit

    export LUAJIT_LIB=/usr/local/luajit/lib
    export LUAJIT_INC=/usr/local/luajit/include/luajit-2.1

    echo "/usr/local/luajit/lib" >> /etc/ld.so.conf
    ldconfig

3.下载nginx的模块

    cd /usr/local/src
    wget https://github.com/simpl/ngx_devel_kit/archive/v0.2.19.tar.gz
    tar zxf v0.2.19.tar.gz
    wget https://github.com/openresty/lua-nginx-module/archive/v0.10.2.tar.gz
    tar zxf v0.10.2.tar.gz

4.卸载nginx1.4.6

aptitude remove nginx

5.安装nginx1.6.3


    cd /usr/local/src

    wget http://nginx.org/download/nginx-1.6.3.tar.gz
    tar zxf nginx-1.6.3.tar.gz
    cd nginx-1.6.3
    ./configure --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_spdy_module --with-http_sub_module --with-http_xslt_module --with-mail --with-mail_ssl_module --add-module=/usr/local/src/ngx_devel_kit-0.2.19 --add-module=/usr/local/src/lua-nginx-module-0.10.2

    make -j 2
    make install 
    ln -s /usr/share/nginx/sbin/nginx /usr/sbin/nginx
    service nginx restart

6.修改nginx配置

location /lua_test {
    content_by_lua_block {
        ngx.say('hello')
    }
}

猜你喜欢

转载自blog.csdn.net/qf0129/article/details/78136574