Ngnix安装error: the HTTP rewrite module requires the PCRE library.

本文详细介绍了如何在Linux环境下安装Nginx所需的依赖组件GCC-C++, PCRE, Zlib及Nginx本身的过程。通过逐步指导,帮助读者解决安装过程中可能出现的问题,如缺少HTTP重写模块等,并验证安装是否成功。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

依次安装:

1、安装GCC-C++,安装Pcre的时候需要

[...]#  yum install -y gcc gcc-c++

2、安装pcre-8.38.zip官网下载即可,安装nginx的时候需要

[...]#  cp /mnt/hgfs/tttmp/pcre-8.38.tar.gz    /opt/

[...]#  gzip -d pcre-8.38.tar.gz
[...]#  tar xvf pcre-8.38.tar
[...]#  cd pcre-8.38
[...]#  ./configure --prefix=/usr/local/pcre-8.38
[...]#  make
[...]#  make install

3、安装Zlib,安装nginx的时候需要


[...]#  cp -a  /mnt/hgfs/tttmp/zlib-1.2.8.tar.gz   /opt/

[...]#  gzip -d zlib-1.2.8.tar.gz
[...]#  tar xvf zlib-1.2.8.tar
[...]#  cd zlib-1.2.8
[...]#  ./configure --prefix=/usr/local/zlib
[...]#  make
[...]#  make install

4、安装完以上的几个组件后,可正常安装Nginx了

[...]#  gzip -d nginx-1.8.1.tar.gz
[...]#  tar xvf nginx-1.8.1.tar
[...]#  cd nginx-1.8.1
[...]#  ./configure --prefix=/usr/local/nginx
[...]#  make
[...]#  make install


但是我在执行 ./configure --prefix=/usr/local/nginx 此命令的时候仍然报错:

error:
./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=<path> option.


之后如下处理,即可正常安装:

[...]#  ./configure --prefix=/usr/local/nginx/ --with-pcre=/opt/pcre-8.38 --with-zlib=/opt/zlib-1.2.8
[...]#  make
[...]#  make install

注意:

--with-pcre=/opt/pcre-8.38  指的是pcre-8.38 的源码路径。

--with-zlib=/opt/zlib-1.2.8   指的是zlib-1.2.8 的源码路径。

 验证是否安装成功:

[...]#  cd /usr/local/nginx/
[...]#  cd sbin/
[...]#  ./nginx
[...]#  netstat -ano|grep 80
[...]#  ./nginx -s reload

如果在浏览器中输入本机IP或者localhost能返回 Welcome to nginx! 则表示 Nginx 已经安装并运行成功。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值