[Ubuntu] Apache2 http2 config

Update your apache version

sudo add-apt-repository -y ppa:ondrej/apache2
sudo apt-key update
sudo apt-get update
sudo apt-get --only-upgrade install apache2 -y

apache2.conf (Y/I/N/O/D/Z) [default=N] ? press Y both the times and proceed. Check your mods-available folder you will see http2.load file

sudo a2enmod http2
sudo service apache2 restart

check /etc/apache2/mods-enabled/http2.load is existed add new a file /etc/apache2/mods-enabled/http2.conf

<IfModule http2_module>         
Protocols h2 h2c http/1.1
LogLevel http2:info

Test http2


Trouble shooting:

cat /var/log/apache2/error.log | grep http2
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.
sudo apachectl stop 
sudo apt-get install php7.1-fpm # Install the php-fpm from your PHP repository. This package name depends on the vendor.
sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php7.1-fpm # Again, this depends on your PHP vendor. sudo a2dismod php7.1 # This disables mod_php.
sudo a2dismod mpm_prefork # This disables the prefork MPM. Only one MPM can run at a time.
sudo a2enmod mpm_event # Enable event MPM. You could also enable mpm_worker.
sudo apachectl start
watch apache enabled modules
apache2ctl -M
Inline Feedbacks
View all comments