【问题标题】:How to install latest version of nginx on raspbian?如何在 raspbian 上安装最新版本的 nginx?
【发布时间】:2017-11-22 13:52:53
【问题描述】:

在 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)

【问题讨论】:

    标签: linux nginx server raspberry-pi debian


    【解决方案1】:

    还有另一种方法可以在 raspbian stretch 上安装 nginx 的最新版本,通过使用 buster 的 repo 以及 raspbian 的 下一个版本 .

    只需要三个命令:

    # 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

    【讨论】:

    • 遵循这些指示似乎已将我从 2017 年 1 月的 1.10.3 更新到 2018 年 12 月的 1.14.2...仍然有 2.5 年历史...看起来像已知的安全性问题列表大约只有一半长...但是有什么方法可以跳到似乎没有已知安全问题的 1.16.1(从 2019 年 8 月开始)?
    • 似乎不再为这种架构(armhf)维护包......您可以考虑使用 docker 的另一种选择。 hub.docker.com/_/nginx/…
    【解决方案2】:

    我遵循@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

    然后我将包更改为引用stretch backport和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

    【讨论】:

    • 谢谢。按照您的建议更改软件包 URL 后,我必须像这样安装 nginx:apt-get install -t stretch-backports nginx -y --allow-unauthenticated
    【解决方案3】:

    您可以使用 Ubuntu 源获取当前最新的 1.13.1,它支持 ALPN 和 HTTP 2.0。 顺便说一句:最好将对您的 apt 源的修改放在 sources 字典而不是 sources.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
    

    完成。

    【讨论】:

    • 在 Raspbian Stretch 上,它没有更改提供的版本。 ``` 已安装:(无)候选:1.10.3-1+deb9u1~bpo8+2 版本表:1.10.3-1+deb9u1 500 500 mirrordirector.raspbian.org/raspbianstretch/main armhf Packages 1.10.3-1+deb9u1~bpo8 +2 990 990 httpredir.debian.org/debian jessie-backports/main armhf 软件包```
    • 你需要通过 apt-get -t jessie-backports install nginx 安装 Nginx
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-02
    • 2015-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多