nginx 编译错误 the HTTP rewrite module requires the PCRE library
问题描述
编译 nginx 1.19.0,使用 ./configure --prefix=/opt/nginx-1.19.0,出现如下错误。
checking for PCRE library ... not found
checking for PCRE library in /usr/local/ ... not found
checking for PCRE library in /usr/include/pcre/ ... not found
checking for PCRE library in /usr/pkg/ ... not found
checking for PCRE library in /opt/local/ ... not found
./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.解决方法
需要安装 pcre。
1. Mac OS
在官网 http://www.pcre.org/ 中下载 pcre,比如 pcre-8.44.zip,运行:
$ unzip pcre-8.44.zip
$ cd pcre-8.44
$ pwd
/Users/cpm/Downloads/packages/pcre-8.44注意不用编译 pcre,下面 configure nginx 的时候,会自动编译 pcre。
复制 pcre-8.44.zip 解压的源代码路径,重新编译 nginx,运行
./configure --prefix=/opt/nginx-1.19.0 --with-pcre=/Users/cpm/Downloads/packages/pcre-8.442. Ubuntu/Debian
- 使用第1步 Mac OS 的方法
- 在 https://pkgs.org/search/?q=libpcre 页面中,找到与操作系统相对应的
libpcre和libpcre-dev包,并下载安装。 - 或者使用
apt-get命令
sudo apt-get install libpcre3-dev3. RHEL / CentOS
- 使用第1步 Mac OS 的方法
- 在 https://pkgs.org/search/?q=pcre 页面中,找到与操作系统相对应的
pcre和pcre-dev包,并下载安装。 - 或者使用
yum命令
sudo yum install pcre-devel