配置好了http2,通过curl -v –http2发现并没有走h2,在/var/log/大概报个这样的warning:

[http2:warn] AH10034: The mpm module (prefork.c) is not supported by mod_http2. The mpm determines how things are processed in your server. HTTP/2 has more demands in this regard and the currently selected mpm will just not do. This is an advisory warning. Your server will continue to work, but the HTTP/2 protocol will be inactive.

大概是mpm的prefork模式和http2不兼容。Google到修补方法:修改mpm模式为event。 参考https://http2.pro/doc/Apache#prefork-http2

sudo service apache2 stop
apt-get install php7.1-fpm # Install the php-fpm from your PHP repository. This package name depends on the vendor.
a2enmod proxy_fcgi setenvif
a2enconf php7.1-fpm # Again, this depends on your PHP vendor.
a2dismod php7.1 # This disables mod_php.
a2dismod mpm_prefork # This disables the prefork MPM. Only one MPM can run at a time.
a2enmod mpm_event # Enable event MPM. You could also enable mpm_worker.
sudo service apache2 start

里面那些带phpx.x的命令需要替换成现在运行的php版本,比如我这里是php7.0。然后就work了。

PS. 另外推荐把php的pm.max_children改大一点,防止php卡顿。