Debug School

Cover image for Upgrade Nginx to the latest version
Suyash Sambhare
Suyash Sambhare

Posted on • Updated on

Upgrade Nginx to the latest version

Follow the below steps to upgrade Nginx to the latest version.

Check current version.
$ nginx -v
nginx version: nginx/1.13.3 (Ubuntu)

Backup the configuration
$ sudo cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.1.13.3.backup

Install any dependencies
$ sudo apt-get install software-properties-common python-software-properties

Add the repository for the stable version of Nginx
$ sudo add-apt-repository ppa:nginx/stable

Update apt repository
$ sudo apt-get update

Run apt install
$ sudo apt-get install nginx

Brahmaputra

Check if you need to keep using the old config or get the new config like this.

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] ?

Enter fullscreen mode Exit fullscreen mode

If you select No, the new version of the current config files is placed in /etc/nginx/sites-available directory.
OR
If you select Yes, it will remove the current config files and replace them.

Check the nginx version again.
$ nginx -v

Here’s what it should say.
nginx version: nginx/1.18.1

Hooray!
The latest version of Nginx is installed.

Ref: https://medium.com/@soban1193/upgrading-nginx-to-the-latest-version-on-ubuntu-c0ad9116cf87

Top comments (0)