OpenResty 编译安装

本文介绍如何下载并安装 OpenResty 1.13.6.1 版本,包括所需依赖库的安装步骤及编译配置选项。适用于 CentOS 7 用户。

1、下载:https://openresty.org/download/openresty-1.13.6.1.tar.gz

  tar -zxvf openresty-1.13.6.1.tar.gz

查看安装了解参数配置帮助文件:http://openresty.org/cn/installation.html

找到对应的系统,我本地使用centos7所以选择了

Fedora 和 RedHat 用户

安装所需扩展(官网没有给出postgresql-devel,我在编译的时候报错:./configure: error: ngx_postgres addon was unable to detect version of the libpq library.)
yum install pcre-devel openssl-devel gcc curl postgresql-devel

./configure --prefix=/usr/local/openresty \
            --with-luajit \
            --without-http_redis2_module \
            --with-http_iconv_module \
            --with-http_postgres_module

make && make install


编译 OpenResty 时指定使用特定版本或配置的 Nginx,可以通过 OpenResty 的构建系统实现。OpenResty 本质上是基于 Nginx 并集成 LuaJIT、ngx_lua 等模块的 Web 平台,因此在编译时可以控制 Nginx 的版本和配置选项。 若希望使用特定版本的 Nginx,可以在 OpenResty 的源码目录中找到 `util/` 目录下的构建脚本,并根据需要修改对应的 Nginx 版本号。OpenResty 的构建系统允许用户自定义 Nginx 的版本,并在编译过程中将其集成到最终的二进制文件中[^1]。 此外,在配置 OpenResty编译参数时,可以通过 `./configure` 命令指定 Nginx 的配置选项。例如,以下是一个典型的 OpenResty 编译命令: ```bash ./configure --prefix=/usr/local/openresty \ --with-http_realip_module \ --with-http_stub_status_module \ --with-http_ssl_module \ --with-pcre \ --with-http_v2_module \ --with-http_gzip_static_module \ --with-http_sub_module \ --with-http_addition_module \ --with-http_flv_module \ --with-http_mp4_module \ --with-http_gunzip_module \ --with-http_random_index_module \ --with-http_secure_link_module \ --with-http_degradation_module \ --with-http_slice_module \ --with-http_perl_module \ --with-http_image_filter_module \ --with-http_xslt_module \ --with-http_geoip_module \ --with-http_upstream_check_module \ --with-http_dav_ext_module \ --with-http_auth_request_module \ --with-http_log_if_module \ --with-http_lua_module \ --with-http_lua_upstream_module \ --add-module=../ngx_http_google_filter_module \ --add-module=../ngx_http_substitutions_filter_module ``` 上述命令中,`--with-http_realip_module`、`--with-http_stub_status_module` 等选项用于启用特定的 Nginx 模块。这些选项可以根据实际需求进行调整。如果需要集成额外的第三方模块,可以使用 `--add-module` 参数指定模块路径[^1]。 在编译 OpenResty 时,还可以通过 `--with-cc-opt` 和 `--with-ld-opt` 参数传递额外的 C 编译器选项和链接器选项。例如,以下命令展示了如何设置额外的编译器选项: ```bash ./configure --prefix=/usr/local/openresty \ --with-cc-opt="-I/usr/local/include" \ --with-ld-opt="-L/usr/local/lib" ``` 上述命令中,`--with-cc-opt` 用于指定头文件搜索路径,而 `--with-ld-opt` 用于指定库文件搜索路径。这些选项在需要链接外部库时非常有用[^1]。 在完成配置后,可以通过以下命令进行编译安装: ```bash make make install ``` 编译完成后,OpenResty 将被安装到指定的目录(如 `/usr/local/openresty`)。可以通过运行以下命令验证安装是否成功: ```bash /usr/local/openresty/nginx/sbin/nginx -v ``` 该命令将显示 Nginx 的版本信息,确认是否使用了预期的版本和配置。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值