-
Note: h2 only works with HTTPS enabled. For a website that is not on https, letsencript can be used.
-
Its would be a good practice to install apache from the following repo, as this repo contains the latest version of apache or nginx which has support for h2.
$ sudo add-apt-repository ppa:ondrej/apache2
$ sudo apt-key update
$ sudo apt-get update
$ sudo add-apt-repository ppa:ondrej/nginx
$ sudo apt-key update
$ sudo apt-get update
- Apache 2.4.27, HTTP/2 not supported in prefork
$ sudo apt-get install software-properties-common
$ sudo add-apt-repository ppa:ondrej/apache2
$ sudo apt-key update
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get --only-upgrade install apache2 -y
- here you will be prompted two times like :
*** apache2.conf (Y/I/N/O/D/Z) [default=N] ?
- press Y both the times and proceed.
$ sudo a2enmod http2
- Update the host file in
$ nano /etc/apache2/sites-available/000-default-le-ssl.conf
<VirtualHost *:443>
[For HTTPS Support]
Protocols h2 http/1.1
[For HTTP Support]
Protocols h2c http/1.1
$ sudo service apache2 restart
$ sudo add-apt-repository ppa:ondrej/php
$ sudo apt-get install -y language-pack-en-base
$ sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
$ sudo apt-get update
$ sudo apt-get install php7.2
$ sudo apachectl stop
$ sudo apt-get install php7.2-fpm
$ sudo a2enmod proxy_fcgi setenvif
$ sudo a2enconf php7.2-fpm
$ sudo a2dismod php7.2
$ sudo a2dismod mpm_prefork
$ sudo a2enmod mpm_event
$ sudo apachectl start
- If you have some problem with
$ sudo a2dismod php7.3
- just try this:
$ sudo a2dismod php7.0
$ sudo a2dismod php7.1
$ sudo service apache2 restart
$ sudo apt-get install php-mysqlnd
- from output of the above command choose explicit version of mysql to be installed.
sudo service apache2 restart
$ sudo nano /var/log/apache2/error.log
- And see what are the errors.
- (skip these steps if you have already updated nginx)
$ sudo add-apt-repository ppa:ondrej/nginx
$ sudo apt-key update
$ sudo apt-get update
$ sudo apt-get install nginx
$ sudo nginx -v
- Should give output something like this
nginx version: nginx/1.10.0 (Ubuntu)
- Open the configuration file
$ sudo nano /etc/nginx/sites-available/default
-
Add http2 as indicated
listen 443 ssl http2 default_server; listen [::]:443 ssl http2 default_server;
-
Save and close the file, then run
$ sudo nginx -t
- This should display the following
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
- Restart nginx service
sudo service nginx restart
- https://serverfault.com/questions/867454/http2-enabled-but-not-supported
- https://askubuntu.com/questions/979323/http-2-not-working-in-ubuntu-16-04-with-apache2-how-can-i-debug-this
- https://www.2daygeek.com/how-to-enable-http2-0-support-on-apache-web-server/2/#
- https://stackoverflow.com/questions/37103927/why-does-apache2-module-http2-not-exist-on-ubuntu-16-04
- https://serverfault.com/questions/515417/error-start-apache-php-value
- https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-with-http-2-support-on-ubuntu-16-04