Problem Description
When compiling and installing Nginx, executing the ./configure command results in the following error:
./configure: error: the Google perftools module requires the Google perftools library. You can either do not enable the module or install the library.
This error indicates that the configuration script detected you enabled the Google perftools module (e.g., using --with-google_perftools_module), but the required Google perftools library (gperftools) is missing from your system.
Solution
You have two options:
- Disable the module: Remove the
--with-google_perftools_moduleparameter from your./configurecommand. - Install the required library: Install the Google perftools development library, then reconfigure and compile Nginx. This is the recommended solution.
Installing the Google Perftools Library
Use your operating system's package manager to install the necessary packages.
On RHEL/CentOS/AlmaLinux/Rocky Linux
Run the following command:
yum install gperftools gperftools-devel
Note: You must install the gperftools-devel package, which contains the header files and libraries needed for compilation. Installing only gperftools may not resolve the error.
On Ubuntu/Debian
Run the following commands:
apt-get update
apt-get install google-perftools libgoogle-perftools-dev
Next Steps
After installing the required library, re-run the Nginx ./configure command (with all your desired parameters), then execute make and make install to complete the installation.
Additional Notes
- Purpose of the Google Perftools Module: This Nginx module binds memory allocation to specific threads (using TCMalloc), which can improve performance in high-concurrency scenarios. If your use case doesn't require it, consider disabling the module during configuration to simplify dependencies.
- Version Compatibility: Ensure the installed gperftools library version is compatible with your Nginx version. Typically, the latest stable version from your system's package manager is sufficient.
- Applicability: This solution applies not only to CentOS but also to other Linux distributions using the
yumordnfpackage managers.