nginx [engine x] is an HTTP and reverse proxy server, a mail proxy server, and a generic TCP/UDP proxy server, originally written by Igor Sysoev. For a long time, it has been running on many heavily loaded Russian sites including Yandex, Mail.Ru, VK, and Rambler. According to Netcraft, Nginx served or proxied 22.36% of the busiest sites in November 2021. Here are some of the success stories: Dropbox, Netflix, WordPress.com, FastMail.FM.
The initial step to upgrade Nginx is taking a backup of your current configuration.
$ sudo cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.backup
Next, we will need to Install the software-properties-common dependencies to add the repository
$ sudo apt-get install software-properties-common
Once the above dependency is installed add the repository for the stable version of the Nginx
$ sudo add-apt-repository ppa:nginx/stable
Now update the changes using the below command
$ sudo apt-get update
Run the below command to install
$ sudo apt-get install nginx
When it asks you if you want to keep using the old config or get the new config like as shown below
Configuration file '/etc/nginx/nginx.conf'
==> Modified (by you or by a script) since installation.
==> Package distributor has shipped an updated version.
What would you like to do about it ? Your options are:
Y or I : install the package maintainer's version
N or O : keep your currently-installed version
D : show the differences between the versions
Z : start a shell to examine the situation
The default action is to keep your current version.
*** nginx.conf (Y/I/N/O/D/Z) [default=N] ?
Select N(No). It will Install the new version of the current config files in
/etc/nginx/sites-available the directory.
Select Y(es) and get the latest config. It will remove current config files.
Now how do we check/validate the version upgrade is successful?
Run the below command to check the version
$ nginx -v
Following will be the output on your console.
nginx version: nginx/1.18.0 (Ubuntu)
Thank you for reading this article, I really appreciate it. If you have any questions feel free to leave a comment.
Official Documentation: – nginx documentation