3分钟教你搞定 nginx 编译安装报错:error the HTTP rewrite module requires the PCRE library
+ [解决办法](#_46)
- 总结
nginx 编译安装报错error: the HTTP rewrite module requires the PCRE library.
前言
今天小编在给大家分享如何编译安装nginx 。编译安装其实不难,我们只需知道去哪里下载安装包。然后解压安装包,进行编译
源码安装 ”三把斧“。
- .configure --user=xx --prefix=安装路径 --help 可以查看先关参数
- make
- make install
对于初学者来说,它难在 它需要很多库文件,如果系统没有,编译就无法进行。今天我就nginx 安装,分析它常见的安装错误
问题描述
- 编译报错
./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.
遇到编译报错,一般都是缺少库文件或者其它文件。我们根据它提示的内容多次进行编译,安装先关文件
最终安装成功!
源码编译安装初次觉得难,多安装几次就变简单了
问题原因
- 缺少安装包,根据提示一步步安装
解决办法
- yum 安装 pcre
# yum 安装prce library
[root@web_server01/usr/src/nginx-1.20.1]# yum -y install pcre
- 根据提示安装模块
# 根据提示:尾部添加 --without-http_rewrite_module
[root@web_server01/usr/src/nginx-1.20.1]# ./configure --user=nginx --prefix=/usr/local/nginx --with-http_ssl_module --with-http_realip_module --with-http_image_filter_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_stub_status_module --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --without-http_rewrite_module
- 再次编译报错:
- 安装openssl openssl-devel
[root@web_server01/opt]# yum -y install openssl openssl-devel
- 再次编译报错:
- 安装gd-devel
# 安装gd-devel
[root@web_server01/usr/src/nginx-1.20.1]# yum -y install gd-devel
总结
== 安装提示==
很重要,我们要根据安装提示进行安装相关文件
如果你不知道文件全称叫啥,还可以通过关键字加*
例如:yum -y install openssl*
- nginx 安装需要安装的环境依赖:
yum -y install pcre-devel openssl openssl-devel gd-devel gcc gcc-c++
- 常见报错提示
./configure: error: SSL modules require the OpenSSL library.