Compiling php with curl, where is curl installed?

110,640

Solution 1

None of these will allow you to compile PHP with cURL enabled.

In order to compile with cURL, you need libcurl header files (.h files). They are usually found in /usr/include/curl. They generally are bundled in a separate development package.

Per example, to install libcurl in Ubuntu:

sudo apt-get install libcurl4-gnutls-dev

Or CentOS:

sudo yum install curl-devel

Then you can just do:

./configure --with-curl # other options...

If you compile cURL manually, you can specify the path to the files without the lib or include suffix. (e.g.: /usr/local if cURL headers are in /usr/local/include/curl).

Solution 2

For Ubuntu 17.0 +

Adding to @netcoder answer above, If you are using Ubuntu 17+, installing libcurl header files is half of the solution. The installation path in ubuntu 17.0+ is different than the installation path in older Ubuntu version. After installing libcurl, you will still get the "cURL not found" error. You need to perform one extra step (as suggested by @minhajul in the OP comment section).

Add a symlink in /usr/include of the cURL installation folder (cURL installation path in Ubuntu 17.0.4 is /usr/include/x86_64-linux-gnu/curl).

My server was running Ubuntu 17.0.4, the commands to enable cURL support were

sudo apt-get install libcurl4-gnutls-dev

Then create a link to cURL installation

cd /usr/include
sudo ln -s x86_64-linux-gnu/curl

Solution 3

Try just --with-curl, without specifying a location, and see if it'll find it by itself.

Share:
110,640
HyderA
Author by

HyderA

Updated on March 29, 2020

Comments

  • HyderA
    HyderA about 4 years

    I need to specify a directory when compiling php with --with-curl=

    The curl binary is located at /usr/bin/curl

    curl -V gives me

    curl 7.15.5 (x86_64-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
    

    locate curl gives me

    /usr/bin/curl
    /usr/lib/libcurl.so.3
    /usr/lib/libcurl.so.3.0.0
    /usr/lib64/libcurl.so.3
    /usr/lib64/libcurl.so.3.0.0
    

    removed /usr/share/... and other irrelevant files

    UPDATE

    Tried --with-curl=/usr/lib64 and --with-curl=/usr/lib although I'm pretty sure it's 64 bit.

    checking for cURL support... yes
    checking if we should use cURL for url streams... no
    checking for cURL in default path... not found
    configure: error: Please reinstall the libcurl distribution -
        easy.h should be in <curl-dir>/include/curl/
    

    SOLUTION

    PHP requires curl-devel

  • HyderA
    HyderA over 13 years
    I did, it couldn't find it at the default location
  • HyderA
    HyderA over 13 years
    Apache is compiled for X86_64, so is my centOS installation. Since curl was installed with it, I'm guessing curl is 64bit as well.
  • HyderA
    HyderA over 13 years
    It's yum install curl-devel on centos, otherwise it's the right answer! Thanks!
  • netcoder
    netcoder over 13 years
    gAMBOOKa: Yes, my bad, I realized it just before I saw your comment. Glad that was it. :)
  • netcoder
    netcoder over 13 years
    @gAMBOOKa: Always keep in mind when compiling PHP (or any C program that is), that you will need the appropriate devel packages for any extension you want to compile that uses an external library.
  • ejfrancis
    ejfrancis over 13 years
    Yep, The curl executable is 64bit, but it also installed 32bit versions of the library(*.so files) so 32bit application can also be linked with the curl library.
  • Capy
    Capy over 11 years
    on Ubuntu is sudo apt-get install libcurl4-gnutls-dev
  • Admin
    Admin almost 11 years
    On CentOS it look like yum install libcurl-devel
  • prashant thakre
    prashant thakre over 9 years
    Thanks yum install curl-devel rocked for me
  • George Hazan
    George Hazan over 7 years
    libcurl4-gnutls-dev package DOES NOT include curl headers, you need to install libcurl4-openssl-dev instead: $sudo apt-get install libcurl4-openssl-dev
  • Ishimwe Aubain Consolateur
    Ishimwe Aubain Consolateur over 3 years
    This actually solved the issue I had on Ubuntu 18.04 while compiling PHP-5.3.22
  • yorch
    yorch over 2 years
    Thanks! the symlink fixed it for me on Ubuntu 20.04 and compiling PHP 5.3.29 with libcurl4-openssl-dev