搭建OpenResty

本文最后更新于:2022年6月1日 下午

openresty官网:http://openresty.org/

安装之前首先要确认系统的基础环境

1. gcc编译器

1
# yum install -y gcc 

2. curl库

1
# yum install -y curl

3. pcre、zlib、openssl开发库(其openssl会依赖pcre和zlib)

1
# yum install -y pcre-devel zlib-devel openssl-devel

4. 如启用postgres模块,还需安装postgresql开发库,否则会报错:ngx_postgres addon was unable to detect version of the libpq library

1
# yum install -y postgresql-devel

5. 准备OpenResty源码包官网下载连接:https://openresty.org/cn/download.html

① 准备安装openresty,解压源码包

1
2
# tar -xvzf openresty-x.x.x.x.tar.gz
# cd openresty-x.x.x.x

② 设置配置选项

1
# ./configure --prefix=/opt/openresty --with-luajit --with-http_iconv_module --with-http_postgres_module

默认的prefix目录为:/usr/local/openresty,这里指定到/opt/openresty

–with-luajit在1.5.8.1之后已经默认开启,不加也是启用的

③ 编译并安装源码

1
2
# make -j4
# make install

6. cd到/opt/openresty/nginx/sbin/,./nginx 来启动nginx,./nginx -s reload 来重启nginx


搭建OpenResty
https://simple2ich4n.top/45893/
作者
2ich4n
发布于
2021年10月8日
更新于
2022年6月1日
许可协议