在 Ubuntu 上安装 nginx-module-brotli 时出现错误

在 Ubuntu 上安装 nginx-module-brotli 时出现错误

我一直尝试在 Nginx 上设置 Brotli 压缩,但在包安装步骤中失败。

特别是当我跑步时sudo apt install nginx-module-brotli,我得到了这个

The following packages have unmet dependencies:
 nginx-module-brotli : Depends: nginx (= 1.17.3-2-ppa7~bionic)
E: Unable to correct problems, you have held broken packages.

但是,我的 Nginx 版本似乎匹配

nginx -V
nginx version: nginx/1.17.3
built by gcc 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) 
built with OpenSSL 1.1.1  11 Sep 2018
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-g -O2 -fdebug-prefix-map=/data/builder/debuild/nginx-1.17.3/debian/debuild-base/nginx-1.17.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie'

任何关于如何修复此问题的建议都值得赞赏。我尝试更新到最新的 Nginx (1.20.x),但同样的问题仍然存在。我也尝试使用从头开始编译它此处指导,结果相同。

编辑:根据评论中的请求

> (base) ubuntu@host:~$ sudo apt update Hit:1
> http://us-west-2.ec2.archive.ubuntu.com/ubuntu bionic InRelease Hit:2
> http://us-west-2.ec2.archive.ubuntu.com/ubuntu bionic-updates
> InRelease                                                    Hit:3
> http://us-west-2.ec2.archive.ubuntu.com/ubuntu bionic-backports
> InRelease                                                  Get:4
> http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB] 
> Hit:5 http://ppa.launchpad.net/hda-me/nginx-stable/ubuntu bionic
> InRelease                                                     Hit:6
> http://nginx.org/packages/ubuntu bionic InRelease                     
> Hit:7 http://ppa.launchpad.net/maxmind/ppa/ubuntu bionic InRelease
> Fetched 88.7 kB in 1s (145 kB/s) Reading package lists... Done
> Building dependency tree        Reading state information... Done 47
> packages can be upgraded. Run 'apt list --upgradable' to see them.
> 

> (base) ubuntu@host:~$ sudo apt install nginx Reading
> package lists... Done Building dependency tree        Reading state
> information... Done The following NEW packages will be installed:  
> nginx 0 upgraded, 1 newly installed, 0 to remove and 47 not upgraded.
> Need to get 877 kB of archives. After this operation, 3,074 kB of
> additional disk space will be used. Get:1
> http://nginx.org/packages/ubuntu bionic/nginx amd64 nginx amd64
> 1.20.2-1~bionic [877 kB] Fetched 877 kB in 1s (668 kB/s) Selecting previously unselected package nginx. (Reading database ... 149038
> files and directories currently installed.) Preparing to unpack
> .../nginx_1.20.2-1~bionic_amd64.deb ...
> ----------------------------------------------------------------------
> 
> Thanks for using nginx!
> 
> Please find the official documentation for nginx here:
> * https://nginx.org/en/docs/
> 
> Please subscribe to nginx-announce mailing list to get the most
> important news about nginx:
> * https://nginx.org/en/support.html
> 
> Commercial subscriptions for nginx are available on:
> * https://nginx.com/products/
> 
> ---------------------------------------------------------------------- Unpacking nginx (1.20.2-1~bionic) ... Setting up nginx
> (1.20.2-1~bionic) ... nginx: [warn] the "ssl" directive is deprecated,
> use the "listen ... ssl" directive instead in
> /etc/nginx/sites-enabled/zdravost:22 Processing triggers for man-db
> (2.8.3-2ubuntu0.1) ... Processing triggers for ureadahead (0.100.0-21)
> ... Processing triggers for systemd (237-3ubuntu10.50) ...

答案1

似乎您有两个提供相同软件包 Ie 的存储库nginx。但是,其中一个存储库还包含 ,nginx-module-brotli它依赖于nginx (= 1.17.3-2-ppa7,而 是由 PPA 提供的hda-me/nginx-stable。您必须删除提供相同软件包 Ie 的其他 PPA,nginx因为您apt会对要安装哪个软件包感到困惑。APT 错误地安装了错误的版本。您必须删除其他存储库,以便只剩下一个版本。这里错误的 PPA 是 ,nginx/stable它提供版本:1.20.2。正确的是 ,它提供所需的hda-me/nginx-stable版本:。1.17.3-2-ppa7nginx-module-brotli

  1. 删除错误的 PPA:

    sudo apt-add-repository --remove nginx/stable
    
  2. 更新:

    sudo apt update
    
  3. 删除错误版本的nginx

    sudo apt remove nginx
    
  4. 安装正确版本的nginx

    sudo apt install nginx
    
  5. 安装所需的包:

    sudo apt install nginx-module-brotli
    

或者,您可以通过重新安装正确的软件包版本来实现相同的目的。但是,不建议这样做,因为这可能会导致依赖性问题,可能导致软件包损坏或阻止软件包升级:

sudo apt install --reinstall nginx=1.17.3-2-ppa7~bionic nginx-module-brotli

相关内容