CURL is a simple module that allows you to connect and communicate to various types of servers using various types of protocols. Curl mainly supports http, https, ftp, gopher, telnet, dict, file, and ldap protocols. It also supports SMB, SMBS, IMAP, IMAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, TFT, HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, and user/password authentication.
We know that, an increasing amount of web applications has made the HTTP scripting more frequently requested and necessary. There is a high demand for such a tool which helps us to automatically extract information from the Web, upload, proxy or POST data to the web servers.
CURL is a simple commandline tool which can be used to do all these URL manipulations and data transfers. It is powered by libcurl, which is a library created by Daniel Stenberg.
It is mandatory to keep such softwares always updated, since there is a chance of hacking attempts, data diddling or loop holes due to old insecure versions. In this article, I’m discussing a simple method on how to update the Curl in a more efficient way to the latest available versions on a cPanel server.
First of all, check the current version installed on the server. Please see the current CURL version in my server below:
root@server1 [/usr/local/src]# /usr/bin/curl -V
curl 7.38.0 (x86_64-redhat-linux-gnu) libcurl/7.38.0 NSS/3.19.1 Basic ECC zlib/1.2.7 libidn/1.28 libssh2/1.4.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smtp smtps telnet tftp
Features: IDN IPv6 Largefile NTLM NTLM_WB SSL UnixSockets
As you can see the CURL version is 7.38 and is compiled to support these many protocols like dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, ldaps, pop3, pop3s, rtsp, scp, sftp, smtp, smtps, telnet and tftp.
We are going to configure CURL with Asynchronous DNS to improve its performance and make the requests more faster without any delays. Let’s start our update process now.
Step 1. Download the latest Curl and Asynchronous DNS Package from their website and extract.
root@server1 [~]# cd /usr/local/src/
root@server1 [/usr/local/src]# wget http://c-ares.haxx.se/download/c-ares-1.10.0.tar.gz
--2016-01-26 06:29:25-- http://c-ares.haxx.se/download/c-ares-1.10.0.tar.gz
Resolving c-ares.haxx.se (c-ares.haxx.se)... 2a00:1a28:1200:9::2, 80.67.6.50
Connecting to c-ares.haxx.se (c-ares.haxx.se)|2a00:1a28:1200:9::2|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 809073 (790K) [application/x-gzip]
Saving to: ‘c-ares-1.10.0.tar.gz’
100%[=====================================================================================================>] 8,09,073 1.18MB/s in 0.7s
2016-01-26 06:29:26 (1.18 MB/s) - ‘c-ares-1.10.0.tar.gz’ saved [809073/809073]
root@server1 [/usr/local/src]#tar -xvf c-ares-1.10.0.tar.gz
root@server1 [/usr/local/src]# wget http://curl.haxx.se/download/curl-7.46.0.tar.gz
--2016-01-26 06:29:59-- http://curl.haxx.se/download/curl-7.46.0.tar.gz
Resolving curl.haxx.se (curl.haxx.se)... 2a00:1a28:1200:9::2, 80.67.6.50
Connecting to curl.haxx.se (curl.haxx.se)|2a00:1a28:1200:9::2|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4551902 (4.3M) [application/x-gzip]
Saving to: ‘curl-7.46.0.tar.gz’
100%[=====================================================================================================>] 45,51,902 3.79MB/s in 1.1s
2016-01-26 06:30:01 (3.79 MB/s) - ‘curl-7.46.0.tar.gz’ saved [4551902/4551902]
root@server1 [/usr/local/src]#tar -xvf curl-7.46.0.tar.gz
Step 2. Configure, make and install the Asynchronous DNS package.
root@server1 [/usr/local/src/c-ares-1.10.0]# ./configure
root@server1 [/usr/local/src/c-ares-1.10.0]# make
make all-am
make[1]: Entering directory `/usr/local/src/c-ares-1.10.0'
/bin/sh ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -DCARES_BUILDING_LIBRARY -DCARES_SYMBOL_HIDING -fvisibility=hidden -g0 -O2 -Wno-system-headers -MT libcares_la-ares__close_sockets.lo -MD -MP -MF .deps/libcares_la-ares__close_sockets.Tpo -c -o libcares_la-ares__close_sockets.lo `test -f 'ares__close_sockets.c' || echo './'`ares__close_sockets.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I. -DCARES_BUILDING_LIBRARY -DCARES_SYMBOL_HIDING -fvisibility=hidden -g0 -O2 -Wno-system-headers -MT libcares_la-ares__close_sockets.lo -MD -MP -MF .deps/libcares_la-ares__close_sockets.Tpo -c ares__close_sockets.c -fPIC -DPIC -o .libs/libcares_la-ares__close_sockets.o
make[1]: Leaving directory `/usr/local/src/c-ares-1.10.0'
root@server1 [/usr/local/src/c-ares-1.10.0]# make install
/usr/bin/install -c -m 644 ares_version.3 ares_inet_pton.3 ares_inet_ntop.3 '/usr/local/share/man/man3'
/usr/bin/mkdir -p '/usr/local/lib/pkgconfig'
/usr/bin/install -c -m 644 libcares.pc '/usr/local/lib/pkgconfig'
make[1]: Leaving directory `/usr/local/src/c-ares-1.10.0'
Step 3. Now configure CURL with Asynchornous DNS and all other required Protocols.
root@server1 [/usr/local/src/curl-7.46.0]# ./configure --enable-ares=/usr/local/src/c-ares-1.10.0 --enable-http --enable-imap --enable-pop3 --enable-ftp --enable-proxy --enable-tftp --enable-ntlm --enable-static --with-ssl=/usr/local/ssl --enable-ipv6 --enable-shared --disable-ldap --enable-gobher --enable-smtp --with-libidn --disable-rtsp --without-zlib
root@server1 [/usr/local/src/curl-7.46.0]#make
curl version: 7.46.0
Host setup: x86_64-pc-linux-gnu
Install prefix: /usr/local
Compiler: gcc
SSL support: enabled (OpenSSL)
SSH support: no (--with-libssh2)
zlib support: no (--with-zlib)
GSS-API support: no (--with-gssapi)
TLS-SRP support: no (--enable-tls-srp)
resolver: c-ares
IPv6 support: enabled
Unix sockets support: enabled
IDN support: enabled
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/pki/tls/certs/ca-bundle.crt
ca cert path: no
LDAP support: no (--enable-ldap / --with-ldap-lib / --with-lber-lib)
LDAPS support: no (--enable-ldaps)
RTSP support: no (--enable-rtsp)
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 FTPS GOPHER HTTP HTTPS IMAP IMAPS POP3 POP3S SMB SMBS SMTP SMTPS TELNET TFTP
root@server1 [/usr/local/src/curl-7.46.0]# make install
Making install in lib
make[1]: Entering directory `/usr/local/src/curl-7.46.0/lib'
make[2]: Entering directory `/usr/local/src/curl-7.46.0/lib'
/usr/bin/mkdir -p '/usr/local/lib'
/bin/sh ../libtool --mode=install /usr/bin/install -c libcurl.la '/usr/local/lib'
libtool: install: /usr/bin/install -c .libs/libcurl.so.4.4.0 /usr/local/lib/libcurl.so.4.4.0
libtool: install: (cd /usr/local/lib && { ln -s -f libcurl.so.4.4.0 libcurl.so.4 || { rm -f libcurl.so.4 && ln -s libcurl.so.4.4.0 libcurl.so.4; }; })
libtool: install: (cd /usr/local/lib && { ln -s -f libcurl.so.4.4.0 libcurl.so || { rm -f libcurl.so && ln -s libcurl.so.4.4.0 libcurl.so; }; })
libtool: install: /usr/bin/install -c .libs/libcurl.lai /usr/local/lib/libcurl.la
libtool: install: /usr/bin/install -c .libs/libcurl.a /usr/local/lib/libcurl.a
libtool: install: chmod 644 /usr/local/lib/libcurl.a
libtool: install: ranlib /usr/local/lib/libcurl.a
libtool: finish: PATH="/usr/local/jdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/X11R6/bin:/root/bin:/sbin" ldconfig -n /usr/local/lib
----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/lib
Step 4 . Edit the file /var/cpanel/easy/apache/rawopts/all_php5 to enable custom CURL module with our downloaded latest asynchronous DNS package as below
root@server1 [~]# vim /var/cpanel/easy/apache/rawopts/all_php5
--with-gssapi
--with-curl=/usr/local/src/curl-7.46.0
--enable-ares=/usr/local/src/c-ares-1.10.0
Step 5. Run EasyApache to configure and install the latest CURL package.
root@server1 [~]#/scripts/easyapache
Step 6. Check and confirm the version and settings of the newly installed Curl version.
root@server1 [~]# curl-config --version
libcurl 7.46.0
root@server1 [/usr/local/src/curl-7.46.0]# curl-config --features --protocols
SSL
IPv6
UnixSockets
AsynchDNS
IDN
NTLM
NTLM_WB
DICT
FILE
FTP
FTPS
GOPHER
HTTP
HTTPS
IMAP
IMAPS
POP3
POP3S
SMB
SMBS
SMTP
SMTPS
TELNET
TFTP
root@server1 [/usr/local/src/curl-7.46.0]# curl --version
curl 7.46.0 (x86_64-pc-linux-gnu) libcurl/7.46.0 OpenSSL/1.0.1e c-ares/1.10.0 libidn/1.28
Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s smb smbs smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile NTLM NTLM_WB SSL UnixSockets
Now you see our CURL is updated to the latest version available CURL 7.46.0and it’s compiled with Asynchronous DNS to support all the required protocols. You can confirm the compiled curl status with a PHPINFO page.
PHP can be coded to make use of these asynchronous CURL requests to fasten the script execution more efficiently. I hope you find this article useful and informative. I would recommend your valuable comments and suggestions on this. Enjoy.