【linux基础】安装openresty

本文详细记录了在内网环境下,由于无法直接使用yum安装openresty,如何手动下载pcre和openssl源码,配置并解决依赖问题,最终成功安装openresty的过程。

由于是内网的原因,不能直接使用yum install -y直接安装,一些安装包都需要自己手动安装,现记录如下。以下报错是在安装过程中,依次报错信息,然后一步一步进行解决。
执行

./configure --prefix=/usr/local/openresty
  • pcre报错信息
    ./configure: error: the HTTP rewrite module requires the PCRE library.
    You can either disable the module by using --without-http_rewrite_module
    option, or install the PCRE library into the system, or build the PCRE library
    statically from the source with nginx by using --with-pcre= option.
  • 安装pcre:
wget https://netix.dl.sourceforge.net/project/pcre/pcre/8.40/pcre-8.40.tar.gz
tar -zxvf pcre-8.40.tar.gz
cd pcre-8.40
./configure --prefix=/usr/local/pcre
make
make install

再执行

./configure --prefix=/usr/local/openresty --with-pcre=/usr/local/pcre
  • openssl报错信息

./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl= option.

  • 安装openssl
    提前使用 whereis zlib 检查是否已安装zlib库
 wget ftp://ftp.openssl.org/source/openssl-1.1.1l.tar.gz
 tar -zxvf openssl-1.1.1l.tar.gz
 cd openssl-1.1.1l
 ./config --prefix=/usr/local/openssl
make
make install

再执行

./configure --prefix=/usr/local/openresty --with-pcre=/usr/local/pcre --with-openssl=/usr/local/openssl

此次configure成功,提示信息有:
Configuration summary
++ using PCRE library: /usr/local/pcre
++ using OpenSSL library: /usr/local/openssl
++ using system zlib library
但是仍然报错:

检查后发现:

./configure --help | grep ‘–with-pcre’

–with-pcre force PCRE library usage
–with-pcre=DIR set path to PCRE library sources
–with-pcre-opt=OPTIONS set additional build options for PCRE
–with-pcre-jit build PCRE with JIT compilation support
也就是–with-pcre是存放源码的路径
解压缩保存一份pcre源码,重新执行:

./configure --prefix=/usr/local/openresty --with-pcre=/usr/local/pcre_src/pcre-8.40 --with-openssl=/usr/local/openssl

此次configure成功,提示信息有:
Configuration summary
++ using PCRE library: /usr/local/pcre_src/pcre-8.40
++ using OpenSSL library: /usr/local/openssl
++ using system zlib library
同理openssl也会报这样的错,–with-openssl也是指向openssl的源码路径,调整后执行:

./configure --prefix=/usr/local/openresty --with-pcre=/usr/local/pcre_src/pcre-8.40 --with-openssl=/usr/local/openssl_src/openssl-1.1.1l

执行成功后,执行

gmake && gmake install

测试openresty

启动openresty

sudo /usr/local/openresty/bin/openresty -p `pwd`/ -c /usr/local/openresty/nginx/conf/nginx.conf

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值