mac-install-openresty

Description

  • 很有幸在2016年的时候接触到OpenResty,OpenResty将强大的Lua嵌入到了Http Server中。这几年工作中也做了些OpenResty项目的落地,比如国际化、商品详情页、动态商品价格、后台权限管理、开放平台等,后来又接触到了基于OpenResty的API网关,比如Orange、Kong等。8月份在北京丽都皇冠假日酒店参加了 agentzh 回国举办的OpenResty 2019 北京技术沙龙,受到了很多启发。最近准备抽出时间整理一下这几年学习和应用OpenResty的经验和踩过的坑,特此记录。

Mac Install OpenResty

  • 利用brew安装OpenResty依赖
  1. brew update
  2. brew install openssl curl
  • 通过brew安装pcre,无法开启pcre-jit以及UTF-8支持,所以通过编译源码安装
  1. wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz

  2. tar -xvf pcre-8.40.tar.gz

  3. 1
    2
    3
    4
    sudo ./configure --prefix=/usr/local/pcre-8.40 \
    --enable-jit \
    --enable-utf8 \
    --enable-unicode-properties
  4. sudo make

  5. sudo make install

  6. 到此 pcre 已支持 JIT ,也可在最后编译 OpenResty 时通过 –with-pcre=/path/to/pcre-xxx/ 指定 pcre 安装路径

  • 安装drizzle模块
  1. wget https://openresty.org/download/drizzle7-2011.07.21.tar.gz
  2. tar zxvf drizzle7-2011.07.21.tar.gz
  3. cd drizzle7-2011.07.21
  4. sudo ./configure –prefix=/usr/local/drizzle –without-server
  5. sudo make libdrizzle-1.0
  6. sudo make install-libdrizzle-1.0
  • ngx_eval - Capturing subrequests response bodies into NGINX variables
  1. git clone https://github.com/openresty/nginx-eval-module.git
  • Auth request module for nginx
  1. git clone git@github.com:PiotrSikora/ngx_http_auth_request_module.git
  • 安装OpenResty
  1. 1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    sudo ./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_module
  2. sudo make -j2

  3. sudo make install

您的支持将鼓励我继续创作!