Table of contents

Nginx configure error: the HTTP rewrite module requires the PCRE library

Nginx Jun 09, 2020 Viewed 20.9K Comments 0

Issue

When configure nginx 1.19.0, run the commands.

./configure --prefix=/opt/nginx-1.19.0

But the following error occurs.

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.

Solution

You need to install pcre.

1. Mac OS

Download pcre in the official website http://www.pcre.org/, such as pcre-8.44.zip, and run:

$ unzip pcre-8.44.zip
$ cd pcre-8.44
$ pwd
/Users/cpm/Downloads/packages/pcre-8.44

Copy your unzip path of pcre-8.44.zip, configure nginx again.

./configure --prefix=/opt/nginx-1.19.0 --with-pcre=/Users/cpm/Downloads/packages/pcre-8.44

2. Ubuntu/Debian

  • Use the method from step 1 above.
  • On the https://pkgs.org/search/?q=libpcre webpage, find the libpcre and libpcre-dev packages that match your operating system, download and install.
  • Use the apt-get command.
sudo apt-get install libpcre3-dev

3. RHEL/CentOS

  • Use the method from step 1 above.
  • On the https://pkgs.org/search/?q=pcre webpage, find the pcre and pcre-devel packages that match your operating system, download and install.
  • Use the yum command.
sudo yum install pcre-devel
Updated Jun 09, 2020