Skip to content

virtualforce/Enabling-h2-protocol-Apache-Nginx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 

Repository files navigation

Enabling h2 (Http/2) protocol for Apache and Nginx

  • 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.

For apache

$ sudo add-apt-repository ppa:ondrej/apache2
$ sudo apt-key update
$ sudo apt-get update

For nginx

$ sudo add-apt-repository ppa:ondrej/nginx
$ sudo apt-key update
$ sudo apt-get update

To enable https use the following links.

Apache

Updating apache2

  • 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

Updating PHP

$ 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

Troubleshooting

  • 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

Updating MYSQL

$ sudo apt-get install php-mysqlnd
  • from output of the above command choose explicit version of mysql to be installed.
sudo service apache2 restart

To check for error go to

$ sudo nano /var/log/apache2/error.log
  • And see what are the errors.

Nginx

Updating Nginx

  • (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)

Changing the Listening Port and Enabling HTTP/2

  • 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

References:

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published