How to install latest version of nginx on raspbian? How to install latest version of nginx on raspbian? nginx nginx

How to install latest version of nginx on raspbian?


There is another way to install the last version of nginx on raspbian stretch, by using the repo of buster the next version of raspbian.

Only three commands are needed:

# Add the url to apt source listecho "deb http://mirrordirector.raspbian.org/raspbian/ buster main contrib non-free rpi" | sudo tee -a /etc/apt/sources.list.d/10-buster.list# Set preferences to give more priority to stretchprintf "Package: *\nPin: release n=stretch\nPin-Priority: 900\n\nPackage: *\nPin: release n=buster\nPin-Priority: 750" | sudo tee -a /etc/apt/preferences.d/10-buster# Update and install: -t is used to target a release and -yqq to confirm and reduce output  sudo apt-get update && sudo apt-get install -t buster nginx -yqq

At the time of writing, the last stable version is 1.14.1.
The same pointed out by sudo apt-get install -t buster -s nginx

Source: https://getgrav.org/blog/raspberrypi-nginx-php7-dev


You can get the current latest, 1.13.1, which supports ALPN and HTTP 2.0 by using the Ubuntu sources. As an aside: it's best to put modifications to your apt sources in the sources dictionary rather than sources.list itself, it helps in terms of maintainability.

Create a file for the repository

sudo touch /etc/apt/sources.list.d/nginx.list

Run the following to add a reference to the Ubuntu repository, and debian jessie backports.

sudo bash -c 'cat << EOF >> /etc/apt/sources.list.d/nginx.list    # jessie-backports, from stretch-level but with no dependencies    deb http://httpredir.debian.org/debian/ jessie-backports main contrib non-free    deb-src http://httpredir.debian.org/debian/ jessie-backports main contrib non-free    # Nginx repository - use Ubuntu 16.04 LTS Xenial to get packages compiled with OpenSSL 1.0.2    deb http://nginx.org/packages/mainline/ubuntu/ xenial nginx    deb-src http://nginx.org/packages/mainline/ubuntu/ xenial nginxEOF'

Update your sources:

sudo apt-get update

Install/Upgrade OpenSSL

sudo apt-get install -t jessie-backports openssl

Install/Upgrade Nginx:

sudo apt-get install nginx

Done.


I followed @Joe's suggestion, it did not work in Raspbian Stretchnginx: Installed: (none) Candidate: 1.10.3-1+deb9u1 Version table: 1.10.3-1+deb9u1 500 500 http://mirrordirector.raspbian.org/raspbian stretch/main armhf Packages 1.10.3-1+deb9u1~bpo8+2 100 100 http://httpredir.debian.org/debian jessie-backports/main armhf Packages

Then I changed packages to refer to stretch backport and debian package instead of Ubuntu,

# stretch-backportsdeb http://httpredir.debian.org/debian/ stretch-backports main contrib non-freedeb-src http://httpredir.debian.org/debian/ stretch-backports main contrib non-free# Nginx pre built packagesdeb http://nginx.org/packages/mainline/debian/ stretch nginxdeb-src http://nginx.org/packages/mainline/debian/ stretch nginx

The new one gives me

nginx: Installed: (none) Candidate: 1.13.3-1~bpo9+1 Version table: 1.13.3-1~bpo9+1 990 990 http://httpredir.debian.org/debian stretch-backports/main armhf Packages 1.10.3-1+deb9u1 500 500 http://mirrordirector.raspbian.org/raspbian stretch/main armhf Packages