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.
    
  • 在这里插入图片描述

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

    最终安装成功!

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

问题原因

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

解决办法

  • 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.
    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.
    
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

宝山的博客

谢谢你的支持

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值