Nginx HTTP Server 1.15.4 Released — Here’s How to install / Upgrade on Ubuntu 18.04 | 16.04 LTS

Nginx HTTP server has just been updated to version ( 1.15.4 )… and this brief toturial is going to show students and new users how to install or upgrade to the latest version in Ubuntu 18.10 / 18.04 | 16.04 LTS servers…

This is a mainline release and it brings some bug fixes and a feature introduction that supports “ssl_early_data” directive with OpenSSL, a fix for a socket leak that might occur when using the “error_page” directive to redirect early request processing errors, notably errors with code 400 and more….

While Apache2 HTTP Server is still the most popular web server and still runs majority of the websites and blogs in use today, Nginx is rapidly gaining tractions… and probably the second most popular web server installed, not very far behind Apache2.

Some of the many reasons Nginx HTTP server is rapidly catching up to Apache2 are the ways its manages resources, its speed, simplicity and can be used as a reverse-proxy…. It’s pretty good!

For more about this release, please read the changelog here..

Below is a list of bug fixes and new features introduced with this release….

  • Feature: now the “ssl_early_data” directive can be used with OpenSSL.
  • Bugfix: in the ngx_http_uwsgi_module.
  • Bugfix: connections with some gRPC backends might not be cached when using the “keepalive” directive.
  • Bugfix: a socket leak might occur when using the “error_page” directive to redirect early request processing errors, notably errors with code 400.
  • Bugfix: the “return” directive did not change the response code when returning errors if the request was redirected by the “error_page” directive.
  • Bugfix: standard error pages and responses of the ngx_http_autoindex_module module used the “bgcolor” attribute, and might be displayed incorrectly when using custom color settings in browsers.
  • Change: the logging level of the “no suitable key share” and “no suitable signature algorithm” SSL errors has been lowered from “crit” to “info”.

Option 1: Installing Nginx from its Mainline Repository

All Nginx’s latest features get released in its mainline repository first… after they’re tested and proven, they’re then promoted to the stable repository to use in a production environment…

To install Nginx HTTP server from its Mainline repository, run the commands to add Nginx’s repository key to Ubuntu. You’ll need to install the key in order for Ubuntu to trust packages from that repository.

cd /tmp/ && wget

After adding the key, run the commands below to install Nginx’s Mainline repository or branch on Ubuntu.

sudo sh -c "echo 'deb '$(lsb_release -cs)' nginx' > /etc/apt/sources.list.d/NginxMainline.list"

When you’re done, all you need to so is run the commands below to install the latest version of Nginx.

sudo apt-get update
sudo apt-get install nginx

Option 2: Installing Nginx From Its Stable Repository

Another option is to install Nginx from its stable branch or repository. To install Nginx from the stable branch, run the commands below to install Nginx stable repository on Ubuntu.

sudo sh -c "echo 'deb '$(lsb_release -cs)' nginx' > /etc/apt/sources.list.d/NginxStable.list"

This assumes you have already added Nginx’s repository key to Ubuntu by running the first commands above.

After adding the repository key, run the commands below to install Nginx.

sudo apt-get update
sudo apt-get install nginx

Managing Nginx Web Server

After you installed Nginx server, it might be better to learn some of the basic commands used to manage it. The lines below show you how to stop, start, restart and reload Nginx

— Stops the server:  sudo systemctl stop nginx.service

— Start the server:  sudo systemctl start nginx.service

— Restarts the server: sudo systemctl restart nginx.service

— Reload config changes no stops:  sudo systemctl reload nginx.service

Configure Nginx HTTP Server

Nginx.conf is the main configuration file. It puts the pieces together by including all remaining configuration files when starting up the web server.

The configuration file is stored at /etc/nginx/nginx.conf

When Nginx is installed on Ubuntu servers, the default document root directory is located at /var/www/html. Just as with Apache2 server on Ubuntu.

Any file you place in the root directory ending in .html and properly formatted with HTML syntax will be served to web clients from that directory…. This is the default location the server looks to server documents saved in .html/.htm

The majority of Nginx configurations files are stored in /etc/nginx directory. In this directory is where you’ll find the server configuration setting files, root directory controls and many of the different configuration settings files to control the server.

Two important locations you’ll spend most of your time are /etc/nginx/sites-available and /etc/nginx/sites-enabled

The sites-available directory contains all the available sites. This is the location you create new site configuration files, and sites-enabled directory contains all sites that are enabled. By default, sites are not enabled until you run a commands to enable them.

The first default site configuration file is /etc/nginx/sites-available/default

This file contains the basic Nginx test settings configurations. You can keep the default site config and continue to use it or copy the it create a new site config file from it…  Make sure to enable the new site though.

Enabling and Disabling Nginx Sites

After creating Nginx sites on Ubuntu something to remember is to always enable the sites…. With Apache2, we showed you how to do that….. Sites can be enabled by running the a2ensite and disable by running the a2dissite commands.

Nginx does not have these available. So to enable a site named on Ubuntu for Nginx HTTP server, just create a symbolic link from the sites-available to the sites-enabled directory.

sudo ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/

To disable the site, just delete it from the sites-enabled directory.

sudo rm /etc/nginx/sites-enabled/

After enabling or disabling a site, restart Nginx server.

sudo systemctl restart nginx.service

To test if Nginx is installed and working, open your browser and browse to the server IP or hostname and you should see Nginx default page if it was installed properly.

Nginx Ubuntu install

You may also like the post below:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.