In our previous guide, we have shown how to easily upgrade Nginx on Ubuntu 14.04 for HTTP/2 support. The required changes in the /etc/nginx/sites-enabled/default
file, /etc/nginx/nginx.conf
file and limitations of that way of installation has been discussed on this article. In this guide, we will show how to install Nginx HTTP/2 with ALPN on Ubuntu 14.04 from ondrej/nginx PPA. It simply means, we really do not need to compile Nginx from source, avoid downtime of a live website. However, this way demands a slight more working knowledge, i.e. it is not exactly easy like the Nginx development PPA way. But this Nginx on Ubuntu 14.04 will deliver HTTP/2 with ALPN support.
Needed Preparation To Install Nginx HTTP/2 With ALPN on Ubuntu 14.04 From ondrej/nginx PPA
As obvious step, we need to take the back of /etc/nginx/sites-enabled/default
file (or /etc/nginx/sites-enabled
directory for many virtual hosts), /etc/nginx/nginx.conf
file preferably as GitHub secret gist, so that in case our method fails and the these config files get overwritten, we can switch PPA to the old Nginx development and use these config files.
Secondly, if you have added Nginx development PPA or other PPA, you need to remove it. cd
to /etc/apt/sources.list.d
and run ls
:
---
1 2 | cd /etc/apt/sources.list.d ls |
If you notice any list with nginx
keyword, remove it/them with rm
command. Also check /etc/apt/sources.list
file for any added PPA specific to Nginx and remove them if present. Run apt update
.
Adding PPAs and Upgrading OpenSSL to Install Nginx on Ubuntu 14.04 For HTTP/2 With ALPN
Basically, commonly we use ondrej/php
PPA, that has newest needed OpenSSL. If we add both PPA by Ondřej Surý, we can update OpenSSL. Simply run these commands :
1 2 3 4 | sudo add-apt-repository -y ppa:ondrej/php sudo add-apt-repository -y ppa:ondrej/nginx sudo apt-get update sudo apt-get upgrade openssl |
You can remove ppa:ondrej/php
later from by cd
–ing to /etc/apt/sources.list.d
, running ls
and deleting any PHP specific list. Otherwise while running sudo apt-get upgrade
, your PHP will try to become PHP 7.
Install Nginx HTTP/2 With ALPN on Ubuntu 14.04 From ondrej/nginx PPA
Now, we need to mock building Nginx, source it to check whether our needed version is getting pulled and install it. If we directly run compiled Nginx, it may again fallback to old version of OpenSSL build. This way will give the room to add any modules as well. If you run apt-get install nginx
or apt-get install nginx-extras
, OpenSSL version will shows as 1.0.2, but nginx -V
will always show that it is built with 2014’s OpenSSL.
1 2 3 4 5 6 7 | sudo apt-get install -y dpkg-dev sudo mkdir /opt/nginx cd /opt/nginx sudo apt-get source nginx sudo apt-get -y build-dep nginx cd nginx-1.* sudo dpkg-buildpackage -b |
During running the above commands, you should check the source files. At final step we need to stop our installed, running Nginx, then install our custom version of Nginx on Ubuntu 14.04 for HTTP/2 with ALPN support. Run these commands :
1 2 3 4 | cd /opt/nginx sudo service nginx stop sudo dpkg --install nginx_1.*~trusty_amd64.deb sudo service nginx start |
In case the method fails, you need to purge Nginx, use the nginx_1.*~trusty_amd64.deb
file to install the Nginx. That is quite unlikely, but still we have /etc/nginx/sites-enabled
directory for many virtual hosts), /etc/nginx/nginx.conf
file preferably as GitHub secret gist as fail safe measure.
Obviously, you will use the tools like described in the previous guide to check whether Google Chrome and SSL Labs test to really understand that your server has HTTP/2 with ALPN support. You need to troubleshoot in case there is problem. This is official repo of Ondřej Surý :
1 | https://launchpad.net/~ondrej |
Kindly consider to motivate him with small donation. Your $10 donation is enough as individual user.
Plan for Upgrading to Ubuntu 16.04 LTS
As next step of server administration, you should plan to upgrade PHP to PHP 7. You need to adjust some path as like we written before. Now, if you follow all the steps including upgrading to PHP 7, your all softwares, /etc/nginx/sites-enabled/default
file, /etc/nginx/nginx.conf
file, PHP-FPM files are upgraded and became forward compatible with Ubuntu 16.04 LTS. As it is impractical to run Ubuntu 14.04 LTS forever from security point of view, you should launch a cloud Server/Virtual server instance running Ubuntu 16.04 LTS, follow our guide to create LEMP server on Ubuntu 16.04 LTS, use your settings files from Ubuntu 14.04 LTS production server. This will create a development environment to check whether everything is fine. You can browse by IP on your website on development environment after importing files, database, even temporary change the IP in DNS to test. After making sure that everything works fine, on your main server (which is probably a dedicated server) take the risk for command line upgrade of Ubuntu 14.04 LTS to Ubuntu 16.04 LTS.
We will not publish any further guide on upgrading to Ubuntu 16.04 LTS or any support to Ubuntu 16.04 LTS anymore. As most of us have upgraded our all servers to Ubuntu 16.04 LTS, chance of security flaw will be higher on Ubuntu 14.04. Within end of September 2016, you should have Ubuntu 14.04. You possibly getting option now for using “do-release-upgrade” on Ubuntu 14.04.
Tagged With install ondrej nginx , Install PHP7 On Ubuntu And Nginx