Score:1

How to enable http/2 from a Centos Package/yum?

cn flag

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

djdomi avatar
za flag
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
in flag
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.
Aussie avatar
cn flag
The first answer on this question is a much better answer to both questions.
Score:1
cl flag
A.B

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
    
Shmack avatar
aw flag
So for Amazon Linux, (this link: https://gist.github.com/dasgoll/42cc52cbac6fc6f5bdec) uses `yum-config-manager --enable epe` then `yum -y install scl-utils`. But httpd24 is no where to be found when running `yum install httpd24`. Stumbled across this: https://wiki.wocommunity.org/display/documentation/Installing+a+deployment+environment+on+RedHat%2C+CentOS+or+Amazon+Linux
Aussie avatar
cn flag
Thanks for the excellent response!
A.B avatar
cl flag
A.B
If it solved your question, feel free to mark the answer as the accepted answer.
Score:-1
za flag
in flag
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.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.