Quantcast
Channel: 碳基体
Viewing all articles
Browse latest Browse all 75

OpenResty安装及结构说明

$
0
0
nginx+Lua成了做云WAF的标配了,所以也要努力学习

以debian/ubuntu环境为例

1.获得源码

wget http://openresty.org/download/ngx_openresty-1.7.2.1.tar.gz

历史版本见 http://openresty.org/

2. 预安装环境
apt-get install libreadline-dev libpcre3-dev libssl-dev  libpq-dev  perl gcc g++ autoconf automake build-essential
3.下载 pcre
(编译nginx时需指定pcre所在目录)

http://sourceforge.net/projects/pcre/files/pcre/8.35/

更多版本 http://sourceforge.net/projects/pcre/files/pcre/

tar zxvf pcre-8.35.tar.gz

4.编译pcre(可选)

cd pcre-8.35/

./configure --enable-jit --prefix=/opt/openresty/pcre

make && make install

5.安装ngx_openresty

tar zxvf ngx_openresty-1.7.2.1.tar.gz

cd ngx_openresty-1.7.2.1/


可以先查看一下支持的配置选项

./configure --help

然后根据所需选择需开启的功能

./configure --prefix=/opt/openresty --with-http_iconv_module --with-http_postgres_module --with-luajit --with-luajit-xcflags=-DLUAJIT_ENABLE_LUA52COMPAT --with-pcre=/opt/pcre-8.35/ --with-pcre-jit --with-http_ssl_module

make

或者机器支持多核,例如双核

make -j2 (

make -j $(getconf _NPROCESSORS_CONF)  可以使用这种方式来获得cpu信息

make install

6.安装其他luajit插件(可选)
示例1: 安装lua Aho-Corasick  AC模式匹配算法插件为例 

(1)下载源码

git clone https://github.com/cloudflare/lua-aho-corasick

(2)编译

make -C /root/lua-aho-corasick/ CFLAGS='-g -O3 -Wall' LUA_INCLUDE_DIR=/opt/openresty/luajit/include/luajit-2.1

make -C /root/lua-aho-corasick/ DESTDIR=/opt/openresty/ PREFIX=luajit install

示例2: 安装luasocket

wget http://files.luaforge.net/releases/luasocket/luasocket/luasocket-2.0.2/luasocket-2.0.2.tar.gz

tar zxvf luasocket-2.0.2.tar.gz

cd luasocket-2.0.2/

编译

make -C /root/luasocket-2.0.2 INSTALL_TOP_SHARE=/opt/openresty/luajit/share/lua/5.1/ INSTALL_TOP_LIB=/opt/openresty/luajit/lib/lua/5.1/ LUAINC="-I /opt/openresty/luajit/include/luajit-2.1" install

安装成功后的openrestry目录结构

OpenResty安装及基本使用 - 碳基体 - 碳基体

 


7.支持的模块简介

http://app.yinxiang.com/l/AAJIQXsu-VRMYpHZXyIpb_gazm_YoOWmr1k/

http://vdisk.weibo.com/s/G_jLEbJqrrxD/1413016756


参考:
http://danqingdani.blog.163.com/blog/static/186094195201402901930116/
http://openresty.org/
https://github.com/openresty
https://github.com/cloudflare
https://github.com/agentzh
https://github.com/jgrahamc
https://github.com/calio

Viewing all articles
Browse latest Browse all 75

Trending Articles