How to Install the Latest Version of curl (7.77.0) on Ubuntu 18.04/20.04 with HestiaCP or VestaCP

How to Install the Latest Version of curl (7.77.0) on Ubuntu 18.04/20.04 with HestiaCP or VestaCP


The default version of curl on Ubuntu servers is often outdated, and no updated package may be readily available in the repositories. This guide provides step-by-step instructions to install the latest version of curl (7.77.0) on Ubuntu 18.04/20.04, including systems running HestiaCP or VestaCP.

What is curl?

curl is a command-line tool and library used to transfer data using URL syntax. It supports various protocols, including HTTP, HTTPS, FTP, FTPS, SCP, SFTP, and more. curl is widely used in scripts, software applications, and even embedded systems such as routers and media players. It offers robust functionality through its underlying library, libcurl, and serves as an essential tool for developers and system administrators.

Installation Steps

Step 1: Remove Existing curl Installation (if any)

To avoid conflicts, remove any pre-installed versions of curl:

apt remove curl
apt purge curl

Step 2: Install Dependencies

Install the required libraries and tools needed to build and run curl:

apt install -y build-essential libcurl4 openssl libssl-dev libssh-dev zlib1g-dev zlib libbrotli-dev brotli \
libkrb5-dev libldap2-dev librtmp-dev libpsl-dev libnghttp2-dev

Step 3: Download and Install curl

Follow these commands to download, compile, and install curl:

cd /usr/local/src
rm -rf curl*
wget https://curl.se/download/curl-7.77.0.tar.gz
tar -xvf curl-7.77.0.tar.gz
cd curl-7.77.0
./configure --with-ssl --with-zlib --with-gssapi --enable-ldap --enable-ldaps --with-libssh --with-nghttp2
make
make install

Step 4: Verify Installation

Check the installed version of curl to confirm the update:

curl -V

Example output:

curl 7.77.0 (x86_64-pc-linux-gnu) libcurl/7.77.0 OpenSSL/1.1.1 zlib/1.2.11 brotli/1.0.4 libidn2/2.0.4
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: AsynchDNS brotli GSS-API HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM NTLM_WB PSL SPNEGO SSL TLS-SRP UnixSockets

Troubleshooting

Issue: Symbol Lookup Errors

If you encounter errors like:

curl: symbol lookup error: curl: undefined symbol: curl_url_cleanup
curl: symbol lookup error: curl: undefined symbol: curl_mime_free

Use the following steps:

1. Install curl build dependencies:

apt build-dep curl

2. Re-run the commands in Step 3 to rebuild and reinstall curl.

3. Update the shared library cache:

ldconfig

Issue: Zlib Not Found

If zlib is missing during installation, install it as follows:

From Repository:

apt install zlib1g-dev zlib1g

From DEB Packages:

cd /usr/local/src
wget http://security.ubuntu.com/ubuntu/pool/main/z/zlib/zlib1g_1.2.11.dfsg-2ubuntu5_amd64.deb
wget http://security.ubuntu.com/ubuntu/pool/main/z/zlib/zlib1g-dev_1.2.11.dfsg-2ubuntu5_amd64.deb
dpkg -i zlib1g_1.2.11.dfsg-2ubuntu5_amd64.deb
dpkg -i zlib1g-dev_1.2.11.dfsg-2ubuntu5_amd64.deb

From Source:

cd /usr/local/src
wget http://www.zlib.net/zlib1211.zip
unzip zlib1211.zip
cd zlib-1.2.11
./configure --prefix=/usr/local/zlib
make && make install

That’s It!

By following this guide, you can successfully install the latest version of curl (7.77.0) on Ubuntu servers running 18.04, 20.04, HestiaCP, or VestaCP. Ensuring you have the latest version of curl enhances compatibility with modern protocols and secures your data transfers. For additional features or troubleshooting, refer to the official curl documentation.