linux – 如何在centos 7中启用apache-http / 2?

我已按照以下链接启用centos-7 apache中的http / 2.
https://www.tunetheweb.com/performance/http2/

我的openssl版本:

# openssl version
OpenSSL 1.1.0f  25 May 2017

安装最新的apr-util和apache时(httpd-2.4.27)
make命令发生以下错误

在apr-util文件夹中:

# 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

在httpd文件夹中:

#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

解决方法:

我建议从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/开始安装随时可用的软件包

或者,您可以从Fedora或CodeIT提供的SRPM重新编译它(与更改的默认值和openssl路径相同):

rpmbuild -ba ~/rpmbuild/SPECS/httpd.spec
上一篇:使用PHP发出HTTP / 2请求


下一篇:服务器配置https与http2协议