18

It seems like curl packed with ubuntu 16.04 does not have http2 support. How do I enable http2 in curl

Tachyons
  • 17,281

1 Answers1

46

As of now (Jan 2018). You will have to install curl from source to get http2 support. You can do that using the following commands

sudo apt-get -y install build-essential nghttp2 libnghttp2-dev libssl-dev
wget https://curl.haxx.se/download/curl-7.63.0.tar.gz
tar xzf curl-7.63.0.tar.gz
cd curl-7.63.0
./configure --with-nghttp2 --prefix=/usr/local --with-ssl
make && sudo make install
sudo ldconfig
evandrix
  • 117
  • 1
  • 6
Tachyons
  • 17,281
  • @user535733 Can you please explain why ? – Tachyons Feb 19 '17 at 15:08
  • I find that uninstalling the packaged version first is a good idea for two reasons: 1) It prevents system conflicts (Error: /usr/bin/curl already exists). 2) It prevents user confusion (I thought I was using the new one) – user535733 Feb 19 '17 at 16:01
  • 2
    @user535733 . Thanks, this will install curl inside /usr/local So it won't collide with the default installation. You can even use them side by side. – Tachyons Feb 20 '17 at 16:01
  • Trying to install libnghttp2-dev gives dependencies issues: libnghttp2-dev : Depends: libnghttp2-14 (= 1.7.1-1) but 1.10.0-1+deb.sury.org~trusty+1 is to be installed How to fix? – Nijboer IT May 06 '17 at 07:58
  • okey fixed it, downgraded to the required version: sudo apt-get install libnghttp2-14=1.7.1-1 – Nijboer IT May 06 '17 at 08:18
  • 2
    If it's still not working, then you may need to restart shell or clear your hash if you've used /usr/bin/curl lately. https://askubuntu.com/q/923527/453746 – Jeff Puckett Jun 08 '17 at 22:05
  • 3
    Most likely you'll want to compile with ssl support as well. Then install sudo apt-get install libssl-dev first and add run configure command this way: ./configure --with-nghttp2 --prefix=/usr/local --with-ssl=/usr/local/ssl – Stalinko Aug 28 '17 at 09:19
  • @Stalinko I think it is enabled by default, can you please confirm? – Tachyons Aug 28 '17 at 11:56
  • 2
    @Tachyons in my case it wasn't. I think it depends on env settings. When you don't pass this parameter deliberately then configure reads it from env variables OPENSSL_CFLAGS and OPENSSL_LIBS – Stalinko Aug 28 '17 at 17:22
  • I did it exactly, no error message, but curl -V doesn't list HTTP2 in Features. – Tibor Nagy Nov 08 '19 at 15:10
  • @TiborNagy Try /usr/local/bin/curl -V – Tachyons Nov 09 '19 at 17:04
  • @Tachyons curl -V is using also the correct path, /usr/local/bin is at the beginning of my $PATH and I see also from the version, that the correct curl instance is called. BTW the output is url 7.63.0 (x86_64-pc-linux-gnu) libcurl/7.47.0 OpenSSL/1.0.2g zlib/1.2.8 libidn/1.32 librtmp/2.3 Release-Date: 2018-12-12 Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP UnixSockets – Tibor Nagy Nov 11 '19 at 16:25