PCRE库缺失问题

lrd

问题

在阿里云Ubuntu 26.04自编译安装Nginx遇到PCRE库缺失

报错如下:

1
2
3
4
./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.

解决方法

  1. 下载最新PCRE包:https://github.com/PCRE2Project/pcre2/releases
  2. 解压进入目录
1
2
tar zxvf pcre2-x.xx.tar.gz
cd pcre2-x.xx
  1. 编译安装
1
2
3
./configure
make
make install
  1. 更新动态链接器缓存
1
ldconfig

Q&A

为什么不用 apt-get install libpcre3-dev?

因为会遇到报错:

1
Package libpcre3-dev is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source.
  • Title: PCRE库缺失问题
  • Author: lrd
  • Created at : 2026-08-08 15:00:00
  • Updated at : 2026-08-08 16:00:00
  • Link: https://blog.lrd0.top/PCRE/
  • License: This work is licensed under CC BY-NC-SA 4.0.
On this page
PCRE库缺失问题