Updating php curl on Ubuntu

Sometime it happens, when

is not enough. And you really want to upgrade your curl to the latest possible version.

Below is the simple guide:

So, to update curl somewhere on the ubuntu:
1/ Assuming we’re logged in as root and we’re in our home directory.

You can update the archive url, pick one from here http://curl.haxx.se/download.html.

2/ Now we need to prepare the instruments for the further actions

3/ Let’s unpack the curl source code

4/ And do the installation

This way we would compile the curl and libcurl (which is very important step) for our system.
The libtool thing, which we’ve installed before is used during the ./buildconf, and make is make.

5/ Now let’s update our system’s binaries.

6/ To finish everything – we should restart every application, which uses PHP

 

That’s all, now we have our curl updated.

updating php curl on Ubuntu

updating php curl on Ubuntu

  • slavafomin

    Thanks!

    However, I have to do: apt-get install libtool make autoconf on Ubuntu 14.04.2 in order to compile the library.

    Also, it’s probably better to create symlink for the binary instead of making another copy of it: ln -s /usr/local/bin/curl /usr/bin/curl.

    • why do we need autoconf? where to use it and how?

      also, symlink isn’t a good idea, we changed the version so move the files in from local folder i guess

  • Pingback: Update libcurl ubuntu 10.04.4 LTS | DL-UAT()

  • Pingback: Update libcurl on ubuntu 10.04.4 LTS topic | ubuntu()

  • before step 4, add: cd curl-7.xxxxxx so that the user is in that folder before he does all other stuff

    • Mário Pedro

      everything was going right until i got an issue when reaching the “make install” part. first i got:

      /usr/bin/install: cannot create regular file ‘/usr/local/lib/libcurl.so.4.4.0’: Permission denied
      make[2]: *** [install-libLTLIBRARIES] Error 1
      make[2]: Leaving directory /home/mmeirolas/Área de Trabalho/curl-7.48.0/lib'
      make[1]: *** [install-am] Error 2
      make[1]: Leaving directory
      /home/mmeirolas/Área de Trabalho/curl-7.48.0/lib’
      make: *** [install-recursive] Error 1

      then i tried with “sudo make install” and i got:

      /bin/bash: /home/mmeirolas/Área: No such file or directory
      make[2]: *** [install-libLTLIBRARIES] Error 127
      make[2]: Leaving directory /home/mmeirolas/Área de Trabalho/curl-7.48.0/lib'
      make[1]: *** [install-am] Error 2
      make[1]: Leaving directory
      /home/mmeirolas/Área de Trabalho/curl-7.48.0/lib’
      make: *** [install-recursive] Error 1

      could you please point me in the right direction?

      • Hi Mario,

        If you have permission denied error, probably you need to run this command with sudo.

        • read his comment, he said that he did that, duh, be careful please next time.

      • are you in the right directory?

    • I have updated the post, thanks for the hint

  • Satellite1

    Almost as easy as it reads, but I’m getting an issue with Ubuntu Apache 2.4 sees 7.47.1 after update, yet PHP is seeing 7.35.[old version] from info.php. How do you get PHP to see the update?

    • robhuffstedtler

      You may need to run a
      sudo ldconfig

      to update the dynamic linker cache

  • carmas75

    Thanks for the info, but now I still have the old libcurl version

    ~# curl -V
    curl 7.48.0 (x86_64-unknown-linux-gnu) libcurl/7.35.0

    so when I try –unix-socket option, it’s not known

    # curl –unix-socket /var/run/docker.sock http:/containers/json
    curl: (48) An unknown option was passed in to libcurl

    • Hi carmas75,

      Probably it means that this version of curl /usr/local/bin/curl is not up to date.
      If you have installed curl successfully, this particular binary should return the newest version.

      Regards,

      • carmas75

        That would be strange, since I’ve followed all the steps and they all were successful.
        As a matter of fact if I move to /usr/bin and run the version for the new curl and the old one, I can see different curl version, but the library is still the same:

        root@carlo-ThinkPad-W541:/usr/bin# curl -V
        curl 7.48.0 (x86_64-unknown-linux-gnu) libcurl/7.35.0 OpenSSL/1.0.1f zlib/1.2.8 libidn/1.28 librtmp/2.3
        Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smtp smtps telnet tftp
        Features: AsynchDNS IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP
        root@carlo-ThinkPad-W541:/usr/bin# curl.bak -V
        curl 7.35.0 (x86_64-pc-linux-gnu) libcurl/7.35.0 OpenSSL/1.0.1f zlib/1.2.8 libidn/1.28 librtmp/2.3
        Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smtp smtps telnet tftp
        Features: AsynchDNS GSS-Negotiate IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP
        root@carlo-ThinkPad-W541:/usr/bin#

        • ok, then, probably your particular php is configured to use different curl, not from /usr/bin . I think you need to dig in that direction then 🙂

          • carmas75

            Thanks Pavel,
            I need to look more at it, also because php is not installed

            root@carlo-ThinkPad-W541:~# php
            The program ‘php’ is currently not installed. You can install it by typing:
            apt-get install php5-cli

          • glad you have managed that!

          • carmas75

            Hi Pavel,
            I still have an issue here. Looks like that building curl that way did not add support for HTTPS protocol.

            carlo@carlo-ThinkPad-W541:/usr/bin$ curl -sS “https://storage.googleapis.com/kubernetes-release/release/stable.txt”

            curl: (1) Protocol “https” not supported or disabled in libcurl

            So I’ve checked the configuration and there is no support for SSL

            I’ve run ./configure again adding the exact path of my SSL library

            ./configure –with-ssl=/lib/x86_64-linux-gnu/

            The result did not change:

            configure: Configured to build curl/libcurl:
            curl version: 7.48.0
            Host setup: x86_64-unknown-linux-gnu
            Install prefix: /usr/local
            Compiler: gcc
            SSL support: no (–with-{ssl,gnutls,nss,polarssl,mbedtls,cyassl,axtls,winssl,darwinssl} )
            SSH support: no (–with-libssh2)
            zlib support: enabled
            GSS-API support: no (–with-gssapi)
            TLS-SRP support: no (–enable-tls-srp)
            resolver: default (–enable-ares / –enable-threaded-resolver)
            IPv6 support: enabled
            Unix sockets support: enabled
            IDN support: no (–with-{libidn,winidn})
            Build libcurl: Shared=yes, Static=yes
            Built-in manual: enabled
            –libcurl option: enabled (–disable-libcurl-option)
            Verbose errors: enabled (–disable-verbose)
            SSPI support: no (–enable-sspi)
            ca cert bundle: /etc/ssl/certs/ca-certificates.crt
            ca cert path: no
            ca fallback: no
            LDAP support: no (–enable-ldap / –with-ldap-lib / –with-lber-lib)
            LDAPS support: no (–enable-ldaps)
            RTSP support: enabled
            RTMP support: no (–with-librtmp)
            metalink support: no (–with-libmetalink)
            PSL support: no (libpsl not found)
            HTTP2 support: disabled (–with-nghttp2)
            Protocols: DICT FILE FTP GOPHER HTTP IMAP POP3 RTSP SMTP TELNET TFTP
            root@carlo-ThinkPad-W541:~/curl-7.48.0#

            Any idea how to fix this?

          • I think you are doing it right with adding the –with-ssl flag, probably you need to experiment with the value of this parameter.

          • carmas75

            I needed libssl-dev to make it working correctly.
            Now it’s ok

          • carmas75

            Found the issue.
            Looks like an AT&T VPN agent was loading the old libcurl library.
            Once modified /etc/ld.so.conf putting /usr/local/bin on top and executed ldconfig I have what I need

            root@carlo-ThinkPad-W541:~# curl -V
            curl 7.48.0 (x86_64-unknown-linux-gnu) libcurl/7.48.0

            Thanks again Pavel for support.

  • Albert Boada

    What could be the reason for my php (phpinfo) not reflecting the new cURL version? (altho if I do $> curl –version, the version is correct).

  • Knstntn Vn

    Thanks for the post! I’ve updated the cURL on Debian to curl 7.39.0 although php info still shows
    “cURL Information 7.26.0” should I update anything else? apache’s curl.so maybe? Thanks in advance!