Description
- 很有幸在2016年的时候接触到OpenResty,OpenResty将强大的Lua嵌入到了Http Server中。这几年工作中也做了些OpenResty项目的落地,比如国际化、商品详情页、动态商品价格、后台权限管理、开放平台等,后来又接触到了基于OpenResty的API网关,比如Orange、Kong等。8月份在北京丽都皇冠假日酒店参加了 agentzh 回国举办的OpenResty 2019 北京技术沙龙,受到了很多启发。最近准备抽出时间整理一下这几年学习和应用OpenResty的经验和踩过的坑,特此记录。
Mac Install OpenResty
- 利用brew安装OpenResty依赖
- brew update
- brew install openssl curl
- 通过brew安装pcre,无法开启pcre-jit以及UTF-8支持,所以通过编译源码安装
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz
tar -xvf pcre-8.40.tar.gz
1
2
3
4sudo ./configure --prefix=/usr/local/pcre-8.40 \
--enable-jit \
--enable-utf8 \
--enable-unicode-propertiessudo make
sudo make install
到此 pcre 已支持 JIT ,也可在最后编译 OpenResty 时通过 –with-pcre=/path/to/pcre-xxx/ 指定 pcre 安装路径
- 安装drizzle模块
- wget https://openresty.org/download/drizzle7-2011.07.21.tar.gz
- tar zxvf drizzle7-2011.07.21.tar.gz
- cd drizzle7-2011.07.21
- sudo ./configure –prefix=/usr/local/drizzle –without-server
- sudo make libdrizzle-1.0
- sudo make install-libdrizzle-1.0
- ngx_eval - Capturing subrequests response bodies into NGINX variables
- Auth request module for nginx
- git clone git@github.com:PiotrSikora/ngx_http_auth_request_module.git
- 安装OpenResty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15sudo ./configure --prefix=/usr/local/openresty \
--with-cc-opt="-I/usr/local/opt/openssl/include/ -I/usr/local/opt/pcre/include/" \
--with-ld-opt="-L/usr/local/opt/openssl/lib/ -L/usr/local/opt/pcre/lib/" \
--with-luajit \
--with-debug \
--with-pcre=/Users/liulei18/Desktop/openresty/pcre-8.40 \
--with-pcre-jit \
--with-http_iconv_module \
--with-http_postgres_module \
--with-http_drizzle_module \
--with-libdrizzle=/usr/local/drizzle \
--with-http_realip_module \
--with-http_stub_status_module \
--add-module=/Users/liulei18/Desktop/openresty/nginx-eval-module \
--add-module=/Users/liulei18/Desktop/openresty/ngx_http_auth_request_modulesudo make -j2
sudo make install