简体   繁体   中英

How to enable apache-http/2 in centos 7?

I have followed the below link for enabling http/2 in centos-7 apache. https://www.tunetheweb.com/performance/http2/

My openssl version :

# openssl version
OpenSSL 1.1.0f  25 May 2017

While installing latest apr-util and apache(httpd-2.4.27) below errors occurred on make command

Inside the apr-util folder :

# make

make[1]: Entering directory `/usr/local/src/apr-util-1.6.0'
/bin/sh /usr/local/apr/build-1/libtool --silent --mode=compile gcc -g -O2 -pthread   -DHAVE_CONFIG_H  -DLINUX -D_REENTRANT -D_GNU_SOURCE   -I/usr/local/src/apr-util-1.6.0/incl
ude -I/usr/local/src/apr-util-1.6.0/include/private  -I/usr/local/apr/include/apr-1    -o xml/apr_xml.lo -c xml/apr_xml.c && touch xml/apr_xml.lo
xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory
 #include <expat.h>
                   ^
compilation terminated.
make[1]: *** [xml/apr_xml.lo] Error 1
make[1]: Leaving directory `/usr/local/src/apr-util-1.6.0'
make: *** [all-recursive] Error 1

Inside the httpd folder :

#make

Making all in srclib
make[1]: Entering directory `/usr/local/src/httpd-2.4.27/srclib'
Making all in apr
make[2]: Entering directory `/usr/local/src/httpd-2.4.27/srclib/apr'
make[3]: Entering directory `/usr/local/src/httpd-2.4.27/srclib/apr'
make[3]: Nothing to be done for `local-all'.
make[3]: Leaving directory `/usr/local/src/httpd-2.4.27/srclib/apr'
make[2]: Leaving directory `/usr/local/src/httpd-2.4.27/srclib/apr'
Making all in apr-util
make[2]: Entering directory `/usr/local/src/httpd-2.4.27/srclib/apr-util'
make[3]: Entering directory `/usr/local/src/httpd-2.4.27/srclib/apr-util'
/bin/sh /usr/local/src/httpd-2.4.27/srclib/apr/libtool --silent --mode=compile gcc -g -O2 -pthread   -DHAVE_CONFIG_H  -DLINUX -D_REENTRANT -D_GNU_SOURCE   -I/usr/local/src/htt
pd-2.4.27/srclib/apr-util/include -I/usr/local/src/httpd-2.4.27/srclib/apr-util/include/private  -I/usr/local/src/httpd-2.4.27/srclib/apr/include    -o xml/apr_xml.lo -c xml/a
pr_xml.c && touch xml/apr_xml.lo
xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory
 #include <expat.h>
                   ^
compilation terminated.
make[3]: *** [xml/apr_xml.lo] Error 1
make[3]: Leaving directory `/usr/local/src/httpd-2.4.27/srclib/apr-util'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/usr/local/src/httpd-2.4.27/srclib/apr-util'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/local/src/httpd-2.4.27/srclib'
make: *** [all-recursive] Error 1

I would suggest to install ready to use package from https://codeit.guru/en_US/2017/10/apache-httpd-2-4-28-built-against-openssl-1-0-2l-with-http2-for-red-hat-enterprise-linux-and-centos/

Alternatively, you can recompile it from SRPM provided by Fedora or CodeIT (the same one with changed defaults and openssl paths):

rpmbuild -ba ~/rpmbuild/SPECS/httpd.spec

@nos was correct and this needed yum install expat-devel and a few other dependencies I already had installed.

I've updated the blog post now to reflect this. Feel free to reach out to me if you've any other issues on this.

Now is available repo from codeit.guru for CentOS 7, it can be enabled:

cd /etc/yum.repos.d && wget https://repo.codeit.guru/codeit.el`rpm -q --qf "%{VERSION}" $(rpm -q --whatprovides redhat-release)`.repo

If apache is already installed, yum update will update apache, it even enables mod_http2 .
Otherwise, fresh installation of apache can be done.

Put Protocols h2 http/1.1 within ssl.conf as Mozilla suggests
Restart apache, http/2 is ready.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM