Compiling php with curl, where is curl installed?

Compiling php with curl, where is curl installed?

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Compiling PHP with cURL: Why --with-curl= Often Fails

When building PHP from source, a common stumbling block arises when attempting to enable cURL support using the --with-curl= flag. Developers often assume that providing the path to the binary is sufficient. However, the compile process frequently fails with an error indicating that easy.h cannot be found in <curl-dir>/include/curl/. This discrepancy exists because the PHP build system needs more than just the executable; it requires the development headers and libraries to generate the necessary code bindings.

Locating the Binary vs. The Headers

In a standard Linux environment, you can find the cURL binary using commands like locate curl or by checking the PATH directly. You will likely see entries such as /usr/bin/curl, along with shared object files like /usr/lib/libcurl.so.3. Running curl -V reveals the installed version and linked libraries, confirming that the runtime component is present.

However, when you pass a path like /usr/lib64 or /usr/lib to the PHP configure script using --with-curl=/path, the script looks for specific files relative to that directory. It expects to find:

  1. The header file curl/curl.h (or specifically easy.h in older configurations).
  2. The static or shared library (libcurl.a or libcurl.so).

If your system has only the development package installed incorrectly, or if you are pointing the compiler to a directory that contains binaries but lacks the corresponding include files, the build will abort. The error message checking for cURL in default path... not found is misleading; it actually means the configure script could not locate the header files required to compile the PHP extension, even though the binary exists at /usr/bin/curl.

The Missing Piece: curl-devel

The solution to this specific compilation error lies in distinguishing between the runtime package and the development package. On RHEL-based distributions (like CentOS or Fedora), the standard curl package installs only the binary and libraries needed to run cURL commands. It does not install the header files necessary for compiling other languages against it.

To resolve this, you must install the curl-devel package. This package provides:

  • The C header file (curl/curl.h) located in /usr/include.
  • The library files required for linking.

Once installed, you can either omit the --with-curl= flag entirely if your system's default paths are standard, or point the configure script specifically to the include directory. For example:

./configure --with-curl=/usr/include

Or, more commonly on modern systems where headers are in /usr/include:

./configure --with-curl=/usr/lib64

The critical step is ensuring that curl-devel is installed before running the configure script. Without it, the compiler cannot find the function prototypes and macro definitions required to wrap cURL functions into PHP classes and streams.

Trade-offs and Common Pitfalls

A frequent mistake is assuming that because a command-line tool works, the development headers are present. Always verify by checking for curl/curl.h in your include path if you decide to use a custom prefix. Additionally, be aware that older versions of cURL (like the 7.15.5 version shown in the source material) might expect easy.h specifically, while newer versions standardize on curl.h. If you encounter header mismatch errors, ensure your PHP build matches the major version series of the installed cURL library.

For production environments using frameworks like Laravel, managing these dependencies via package managers is generally preferred over compiling from source unless you require specific SSL configurations or legacy protocol support that isn't available in official releases.

Our network