2020-06-20 17:50:52
UBUNTU 16.04默认源里的APACHE2没有HTTP2模块,如果启用HTTP2模块一般会报错找不到模块.
a2enmod http2
ERROR: Module http2 does not exist!
所以如果要启用HTTP2模块,需要从源码从头编一个APACHE2.不过编译好的HTTP2模块可以直接拷贝出来使用,所以已经安装过APACHE2了也不需要担心.
首先将源码源加入源列表之中:
vi /etc/apt/sources.list
添加以下:
deb-src http://archive.ubuntu.com/ubuntu/ xenial main universe restricted multiverse
deb-src http://security.ubuntu.com/ubuntu xenial-security main universe restricted multiverse
deb-src http://archive.ubuntu.com/ubuntu/ xenial-updates main universe restricted multiverse
然后刷新源,如果有需要更新的包,顺便升下级:
apt update
apt upgrade
然后安装依赖:
apt install curl devscripts build-essential fakeroot libnghttp2-dev
创建一个工作的编译目录:
cd ~
mkdir apache2
cd apache2
从源里下载APACHE2的源码然后编译:
apt source apache2
apt build-dep apache2
cd apache2-2.4.18
apt install curl devscripts build-essential fakeroot
fakeroot debian/rules binary
将编译的好的HTTP2模块拷贝到APACHE2模块目录中:
cp debian/apache2-bin/usr/lib/apache2/modules/mod_http2.so /usr/lib/apache2/modules/
然后为HTTP2模块编写一个配置文件:
vim /etc/apache2/mods-available/http2.load
在其中写入以下:
LoadModule http2_module /usr/lib/apache2/modules/mod_http2.so
<IfModule http2_module>
LogLevel http2:info
</IfModule>
最后启用HTTP2模块:
service apache2 restart
a2enmod http2
service apache2 restart
编辑网站配置文件,加入HTTP2协议:
vim /etc/apache2/sites-enabled/default-ssl.conf
在默认配置文件的SERVERNAME下添加一行:
Protocols h2 http/1.1
如果没有默认配置文件,可参考以下配置文件:
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin webmaster@localhost
ServerName your-domain.com
Protocols h2 http/1.1
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
<FilesMatch ".(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
</VirtualHost>
</IfModule>
然后还需要将HTTP2协议加入APACHE2配置文件中:
vim /etc/apache2/apache2.conf
加入以下行:
Protocols h2 http/1.1
最后重启APACHE2
service apache2 restart
Nginx HTTP2配置教程
06-23
UBUNTU14.04升级php curl,支持HTTP2发送APNs
03-09
开启nginx的gzip压缩功能,节省流量
05-28
开启因特网连接防火墙(ICF)后局域网内机器如何实现互访?
07-08
360硬件检测软件提示此计算机没有安装能够支持无线网络适配器(802.11.WAN或BLluetooth)
05-14
Promise TX4310 SATA RAID卡最多支持的硬盘、逻辑阵列数
04-02
T400s如何开启或关闭指纹指示灯
05-17
TR260 G2如何开启板载SATA RAID功能
07-12
TR280服务器是否支持USB光驱启动进行系统安装?
06-26
ThinkPad -- 蓝牙支持
05-16
ThinkPad 8 4G网卡如何支持全网通
05-21
Windows 7系统AHCI开启后重启出现蓝屏无法启动或者死机解决方案
04-27
Windows 7系统下如何开启网络发现?
05-19
Windows XP系统下笔记本蓝牙设备无法开启
05-01
zuihou-admin-cloud 1.6 发布,支持自动生成前端页面
07-11
使用第三方分区工具重新划分硬盘分区后,一键恢复时提示“本版本不支持该类型的分区”
06-16
如何开启S10-2的杜比耳机功能
06-16
如何开启睿频技术
05-16
如何开启网卡的网络唤醒功能
07-16
如何在Win7安装U盘中加入USB3.0驱动的支持
04-13