C4f1151075b447779af31e99d6cf70e2c6eb47ac
By:
newbie

how to install the latest nginx stable 1.10.2

November 8, 2016 190 views
Nginx Ubuntu 16.04

Hello,
just created a new droplet on ubuntu 16.04 and installed nginx. but when i checked nginx version is 1.10.1
now i tried to update and upgrade everything but nginx version stays the same. how can i update my nginx to the latest stable version which is 1.10.2?

2 Answers

This is because you install from repository (using apt-get). Packages are repositories are usually not updated 'insta' and you need to wait little bit before installing it using apt-get.

When I install nginx on new Droplet (Ubuntu 16.04) and run nginx -v:

nginx version: nginx/1.10.0 (Ubuntu)

To get around this you need to install from source. This is not straightforward as installing with apt-get but I think it's not very hard.
How To Install Nginx From Source (nginx.com).
Building From Source (nginx.org).
There is no DO tutorial for Ubuntu. I found old one for CentOS which you can read at How To Compile Nginx from Source on a CentOS 6.4 x64 VPS.

by Sairam Kunala
Read how to compile Nginx from source on a CentOS 6.4 x64 VPS.
  • @newbie
    You deleted answer but I'll answer anyways. :)

    This applies to every package. Not every package update finishes in Ubuntu repository. It needs to be tested on multiple platforms and verified. This is why you don't have always latest versions in repository.

    If you want always latest - installing from source is way to go. It is harder to update package and to maintain it.
    You can try to find nightly repositories for packages you use - that means that all updates go in repository and you can use apt-get to get it. Problem is that it's rare to find nightly repositories.

    • @xMudrii
      bro, whats the difference between these 2 commands?

      sudo apt-get update && apt-get dist-upgrade

      sudo apt-get update && apt-get upgrade

      thanks in advance.

      • First part is the same - sudo apt-get update updates apt cache.
        Now, you have sudo apt-get update and sudo apt-get dist-upgrade.

        By some basic definition upgrade replaces the current version of package with newer one. It doesn't install or remove packages, only replaces older with newer. If some package requires additional one at time of upgrade or removing one, upgrade will fail.

        There comes our friend dist-upgrade. It can add new one or remove packages so this is the case when you use it.

        This is especially useful for kernel upgrades and mostly used for it. Because updating kernel is not just replacing current one - it's adding new package for kernel - dist-upgrade is required.

        Also don't forget that you have to run both command as sudo, i.e. sudo apt-get update && sudo apt-get upgrade or if not, second command would fail if user isn't root.

        • great,
          so is it safe to update my droplet using command
          sudo apt-get update && sudo apt-get dist-upgrade

          it will not gonna break anything right?

          • Theoretically, it's unknown is it safe or no. Practically, it's safe. Personally, I done it many times, on personal workstations, development and production machines and never encountered any problem.

            But problem can arise. Chances are very low, but you never know.

            To be on safe side, if you do this on production machine, it's always recommended to make backup or test it on environment similar to it.
            DigitalOcean makes it easy to backup server - you can create Snapshot, do the upgrade and remove Snapshot if everything works.

            Just make sure, if you want to have everything absolute up-to-date, you have to do:

            • sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade

            upgrade will only update set of packages where it doesn't need to install/remove other packages. Where replace of current one will do the job.
            dist-upgrade will update ones which requires to add dependencies or install new package for new version (like kernels). It'll not update ones which can be via upgrade...

            Look at example output of upgrade:

            apt-get upgrade
            The following packages have been kept back:
              liboxideqt-qmlplugin liboxideqtcore0 liboxideqtquick0 oxideqt-codecs-extra
            The following packages will be upgraded:
              neovim qml-module-ubuntu-web qtdeclarative5-ubuntu-web-plugin
              webapp-container webbrowser-app
            5 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.
            

            Yet of dist-upgrade:

            apt-get dist-upgrade
            The following NEW packages will be installed:
              libhybris libmedia1
            The following packages will be upgraded:
              liboxideqt-qmlplugin liboxideqtcore0 liboxideqtquick0 neovim
              oxideqt-codecs-extra qml-module-ubuntu-web qtdeclarative5-ubuntu-web-plugin
              webapp-container webbrowser-app
            

            As you see, it's not same list of packages.
            I hope you understand all this, I tried to explain it well. :D

Have another answer? Share your knowledge.