Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install latest version of nginx on raspbian?

What to specify in source.list? because when I write

deb http://nginx.org/packages/debian/ jessie nginx
deb-src http://nginx.org/packages/debian/ jessie nginx

appears error:

Unable to find expected entry '' in Release file (Wrong sources.list entry or malformed file)
like image 941
evans Avatar asked Jun 20 '17 06:06

evans


People also ask

How do I update Nginx to latest version?

Update nginx to a specific version Go to https://centos.pkgs.org/7/nginx-x86_64/nginx-1.20.1-1.el7.ngx.x86_64.rpm.html#download and download the binary. If you want another version search above the package that you need. Check Nginx version and don't forget to restart nginx service.

How do I install a specific version of nginx?

Your options for that command (for nginx) are: add-apt-repository ppa:nginx/stable - latest release marked as stable. add-apt-repository ppa:nginx/mainline - latest version, usually stable enough for production.

What is the latest version of nginx?

nginx-1.21.6 mainline version has been released. njs-0.7.2 version has been released.


3 Answers

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 list
echo "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 stretch
printf "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

like image 69
MarcosBernal Avatar answered Nov 01 '22 12:11

MarcosBernal


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 nginx
EOF'

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.

like image 32
Joe Brailsford Avatar answered Nov 01 '22 12:11

Joe Brailsford


I followed @Joe's suggestion, it did not work in Raspbian Stretch nginx: 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-backports
deb http://httpredir.debian.org/debian/ stretch-backports main contrib non-free
deb-src http://httpredir.debian.org/debian/ stretch-backports main contrib non-free

# Nginx pre built packages
deb http://nginx.org/packages/mainline/debian/ stretch nginx
deb-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

like image 27
Adarsha Avatar answered Nov 01 '22 11:11

Adarsha