如何在raspbian上安装最新版本的nginx?

时间:2017-06-20 06:59:07

标签: linux nginx server raspberry-pi debian

在source.list中指定什么?因为我写的时候

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

出现错误:

Unable to find expected entry '' in Release file (Wrong sources.list entry or malformed file)

3 个答案:

答案 0 :(得分:2)

还有另一种方法,通过使用 buster 的raspbian的 buster 版本,在raspbian Stretch上安装 nginx的最新版本

只需要三个命令:

# 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

在撰写本文时,last stable version is 1.14.1
sudo apt-get install -t buster -s nginx

指出的同样

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

答案 1 :(得分:1)

您可以使用Ubuntu源获取当前最新的1.13.1,它支持ALPN和HTTP 2.0。 顺便说一下:最好在源代码字典中对apt源进行修改,而不是source.list本身,它在可维护性方面有所帮助。

为存储库创建文件

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

运行以下命令添加对Ubuntu存储库和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'

更新来源:

sudo apt-get update

安装/升级OpenSSL

sudo apt-get install -t jessie-backports openssl

安装/升级Nginx:

sudo apt-get install nginx

完成。

答案 2 :(得分:1)

我遵循@ Joe的建议,它在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

然后我更改了包以引用拉伸后端和debian包而不是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

新的给了我

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