3分钟教你搞定 nginx 编译安装报错:error: the HTTP rewrite module requires the PCRE library.

简介: 3分钟教你搞定 nginx 编译安装报错:error: the HTTP rewrite module requires the PCRE library.

nginx 编译安装报错error: the HTTP rewrite module requires the PCRE library.



前言


今天小编在给大家分享如何编译安装nginx 。编译安装其实不难,我们只需知道去哪里下载安装包。然后解压安装包,进行编译


源码安装 ”三把斧“。


1.configure --user=xx --prefix=安装路径 --help 可以查看先关参数


2.make


3.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=<path> option.


image.png


遇到编译报错,一般都是缺少库文件或者其它文件。我们根据它提示的内容多次进行编译,安装先关文件


最终安装成功!


源码编译安装初次觉得难,多安装几次就变简单了


问题原因


  • 缺少安装包,根据提示一步步安装


解决办法


  • yum 安装 pcre


# yum 安装prce library
[root@web_server01/usr/src/nginx-1.20.1]# yum -y install pcre


  • 根据提示安装模块


image.png


# 根据提示:尾部添加 --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


  • 再次编译报错:


image.png


  • 安装openssl openssl-devel


[root@web_server01/opt]# yum -y install openssl openssl-devel


  • 再次编译报错:


image.png


  • 安装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.
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=<path> option.
./configure: error: the HTTP image filter module requires the GD library.
You can either do not enable the module or install the libraries.
相关文章
|
3天前
|
缓存 负载均衡 应用服务中间件
Nginx安装与使用: Nginx之编译安装的nginx加入systemctl、Nginx命令
Nginx安装与使用: Nginx之编译安装的nginx加入systemctl、Nginx命令
63 0
|
2天前
|
监控 Unix 应用服务中间件
Android-音视频学习系列-(八)基于-Nginx-搭建(rtmp、http)直播服务器
Android-音视频学习系列-(八)基于-Nginx-搭建(rtmp、http)直播服务器
|
2天前
|
负载均衡 应用服务中间件 nginx
解决nginx配置负载均衡时invalid host in upstream报错
在Windows环境下,配置Nginx 1.11.5进行负载均衡时遇到问题,服务无法启动。错误日志显示“invalid host in upstream”。检查发现上游服务器列表中,192.168.29.128的主机地址无效。负载均衡配置中,两个服务器地址前误加了&quot;http://&quot;。修正方法是删除上游服务器列表和proxy_pass中的&quot;http://&quot;。问题解决后,Nginx服务应能正常启动。
32 4
解决nginx配置负载均衡时invalid host in upstream报错
|
3天前
|
存储 Web App开发 安全
如何处理错误消息 HTTP error 421 occurred SSL handshake with github.com
如何处理错误消息 HTTP error 421 occurred SSL handshake with github.com
5 0
|
3天前
|
网络协议 应用服务中间件 nginx
nginx 302 301 设置 url 转跳 nginx 资源重定向 nginx tcp 和 http 转发
nginx 代理后端网站,和 网站资源目录重定向到其他连接地址
69 3
|
3天前
|
Ubuntu 应用服务中间件 nginx
ubuntu编译安装nginx及安装nginx_upstream_check_module模块
以上是编译安装Nginx和安装 `nginx_upstream_check_module`模块的基本步骤。根据你的需求和环境,你可能需要进一步配置Nginx以满足特定的要求。
27 3
|
3天前
|
弹性计算 应用服务中间件 Shell
一键编译安装Nginx脚本
【4月更文挑战第30天】
23 1
|
3天前
|
安全 Go
解决https页面加载http资源报错
请注意,混合内容可能导致安全性问题,因此在使用上述方法时要小心。最好的方式是尽量减少或完全消除混合内容,以确保页面的安全性。
29 0
|
3天前
|
应用服务中间件 nginx
yum 安装报错 No package nginx available Error:Nothing to do
yum 安装报错 No package nginx available Error:Nothing to do
43 1
|
3天前
|
监控 网络安全 PHP
对象存储oss使用问题之操作报错:Unable to execute HTTP request: SocketException如何解决
《对象存储OSS操作报错合集》精选了用户在使用阿里云对象存储服务(OSS)过程中出现的各种常见及疑难报错情况,包括但不限于权限问题、上传下载异常、Bucket配置错误、网络连接问题、跨域资源共享(CORS)设定错误、数据一致性问题以及API调用失败等场景。为用户降低故障排查时间,确保OSS服务的稳定运行与高效利用。
238 0