1

I'm running the following version of Apache on Centos 7:

httpd.x86_64 2.4.6-97.el7.centos.5 @updates

httpd-tools.x86_64 2.4.6-97.el7.centos.5 @updates

This is the default package that came with the system. I want to be able to support http/2 but the instructions I have found require me to build/configure the software with that parameter. However, I'm using a standard package for ease of update. Is there a way to enable this feature and still use the same update tree? Or is there a better package/repo to use? Or is there a way I can configure the existing installation to enable http 2.0? I looked and I didn't see mod_http2.so - is there a way to install that and then enable it via configuration so I don't have to re-build Apache from scratch?

NOTE: There is an existing question ( HTTP/2 on CentOS 7 on Apache with PHP7 ) about this but it's 5 years old and I'm hoping for a more updated answer since at the time it was said http/2 was not as stable/supported

Aussie
  • 27
  • 4
  • if not enabled by default on debian you need to add an additional module to apache, yum should be able to find it but im unfamiliar with it – djdomi Apr 17 '22 at 17:19
  • Since base versions of the distributions don't receive feature updates for their packages, only security fixes, the linked question most probably is still current. – Gerald Schneider Apr 17 '22 at 17:56
  • The first answer on this question is a much better answer to both questions. – Aussie Apr 19 '22 at 14:53

2 Answers2

2

CentOS7 by default is stuck with Apache httpd 2.4.6 which doesn't provide the mod_http2.so module to implement HTTP/2.

Here's how to do with supported software and without recompilation:

  • enable the Software Collections Repository

    These are supported additional packages including newer versions of existing packages. They install in a separate directory (usually /opt/rh) so they won't clash with the original version. This also means there's a bit more effort to use some of their features.

    yum install centos-release-scl
    

    This will install a new repository with the additional packages

  • Install httpd24

    yum install httpd24
    

    which mostly will pull the actual package httpd24-httpd and more importantly for this answer, will pull in turn httpd24-libnghttp2: A library implementing the HTTP/2 protocol.

  • configure the newer installation in its own configuration directories

    Like many SCL packages, this package is intended to be installed without clashing with the package it's replacing, rather than updating it. Most of the configuration files usually found in /etc/httpd are now found in /opt/rh/httpd24/root/etc/httpd.

    So please copy and adapt (if there are some absolute directory references in configurations etc.) the settings over the new place: /opt/rh/httpd24/root/etc/httpd

    This version comes with HTTP/2 enabled:

    # grep -r http2 /opt/rh/httpd24/root/etc/httpd/
    /opt/rh/httpd24/root/etc/httpd/conf.modules.d/00-base.conf:LoadModule http2_module modules/mod_http2.so
    
  • verify syntax etc.

    This is part of SCL peculiarities. One must run preparatory commands to use the correct path and libraries for the added components.

    Interactively (but a non-interactive command could be run immediately instead):

    # scl enable httpd24 -- bash -l
    

    The new shell inherits additional environment:

    # printenv |grep /opt/rh
    MANPATH=/opt/rh/httpd24/root/usr/share/man:
    LIBRARY_PATH=/opt/rh/httpd24/root/usr/lib64
    LD_LIBRARY_PATH=/opt/rh/httpd24/root/usr/lib64
    PATH=/opt/rh/httpd24/root/usr/bin:/opt/rh/httpd24/root/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/bin
    PKG_CONFIG_PATH=/opt/rh/httpd24/root/usr/lib64/pkgconfig
    

    and can now run commands like:

    # httpd -v
    Server version: Apache/2.4.34 (Red Hat)
    Server built:   Feb  1 2022 14:11:48
    
  • Switch the service over

    systemd services are already made to use this new environment, so nothing related to the previous bullet is needed here

    systemctl disable --now httpd
    systemctl enable --now httpd24-httpd
    
A.B
  • 9,037
  • 2
  • 19
  • 37
-1

See Red Hat / Fedora instructions here: https://www.ubuntupit.com/how-to-enable-http-2-in-apache-on-linux-system/

  • Please don't post link only answers. They become useless when the link dies. Instead, post the essence of the link and add the link for reference. – Gerald Schneider Apr 17 '22 at 18:29