DEV Community

Discussion on: How to manage and use Nginx Virtual host in Ubuntu

Collapse
 
peter279k profile image
peter279k • Edited

By default, the Nginx version on Ubuntu 20.04 LTS is outdated.

We can run following command to prove that:

lee@lee-VirtualBox:~$ sudo apt-cache policy nginx
nginx:
  Installed: (none)
  Candidate: 1.18.0-0ubuntu1.2
  Version table:
     1.18.0-0ubuntu1.2 500
        500 http://tw.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
        500 http://tw.archive.ubuntu.com/ubuntu focal-updates/main i386 Packages
        500 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu focal-security/main i386 Packages
     1.17.10-0ubuntu1 500
        500 http://tw.archive.ubuntu.com/ubuntu focal/main amd64 Packages
        500 http://tw.archive.ubuntu.com/ubuntu focal/main i386 Packages
Enter fullscreen mode Exit fullscreen mode

If we want to install the latest Nginx version, it can consider following steps:

  • Running the sudo add-apt-repository ppa:ondrej/nginx -y to import this PPA repository.
lee@lee-VirtualBox:~$ sudo add-apt-repository ppa:ondrej/nginx -y
Hit:1 http://tw.archive.ubuntu.com/ubuntu focal InRelease
Hit:2 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ InRelease
Hit:3 https://download.docker.com/linux/ubuntu focal InRelease
Hit:4 http://tw.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:5 http://tw.archive.ubuntu.com/ubuntu focal-backports InRelease
Hit:6 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:7 http://ppa.launchpad.net/ansible/ansible/ubuntu focal InRelease
Hit:8 http://ppa.launchpad.net/ondrej/nginx/ubuntu focal InRelease
Hit:9 http://ppa.launchpad.net/ondrej/php/ubuntu focal InRelease
Reading package lists... Done
Enter fullscreen mode Exit fullscreen mode
  • Running the sudo apt-cache policy nginx command again and we can notice that we've the latest Nginx version can be installed.
lee@lee-VirtualBox:~$ sudo apt-cache policy nginx
nginx:
  Installed: (none)
  Candidate: 1.20.1-2+ubuntu20.04.1+deb.sury.org+1
  Version table:
     1.20.1-2+ubuntu20.04.1+deb.sury.org+1 500
        500 http://ppa.launchpad.net/ondrej/nginx/ubuntu focal/main amd64 Packages
        500 http://ppa.launchpad.net/ondrej/nginx/ubuntu focal/main i386 Packages
     1.18.0-0ubuntu1.2 500
        500 http://tw.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
        500 http://tw.archive.ubuntu.com/ubuntu focal-updates/main i386 Packages
        500 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu focal-security/main i386 Packages
     1.17.10-0ubuntu1 500
        500 http://tw.archive.ubuntu.com/ubuntu focal/main amd64 Packages
        500 http://tw.archive.ubuntu.com/ubuntu focal/main i386 Packages
Enter fullscreen mode Exit fullscreen mode