文章内容
2025/10/29 0:27:51,作 者: 黄兵
Ubuntu 24.04 E: Unable to locate package nginx-module-brotli
最近在 Ubuntu 24.04 上安装 nginx-module-brotli 压缩模块的时候出现了如下错误:
E: Unable to locate package nginx-module-brotli
出现问题的原因:
原因是 Ubuntu 官方仓库默认 没有提供 Brotli 模块。
解决方案:
安装这两个模块:libnginx-mod-http-brotli-filter 和 libnginx-mod-http-brotli-static,但是经过测试 Ubuntu 22.04 无法安装这两个模块。
这些是 动态模块,在 Ubuntu 24.04 下无需手动编译模块,只需要更改 /etc/nginx/nginx.conf 文件:
##
# brotli Settings
##
brotli on;
brotli_static on;
brotli_comp_level 6;
brotli_buffers 16 8k;
brotli_min_length 1000;
brotli_types
text/plain
text/css
text/javascript
application/javascript
application/json
application/xml
application/rss+xml
image/svg+xml
application/x-font-ttf
font/opentype;
✅ 建议保留 Gzip 兼容
一起保留(gzip 作为 fallback):
gzip on;
gzip_comp_level 5;
gzip_min_length 1k;
gzip_types text/plain text/css application/json application/javascript application/xml image/svg+xml;
gzip_vary on;
gzip_proxied any;
✅ 第四步:验证 Brotli 是否生效
重启 Nginx 后(必须):
sudo systemctl reload nginx
参考资料:
1、E: Unable to locate package nginx-brotli #2094
其它相关推荐:
如何在 Ubuntu 24.04 上安装和配置 Zabbix Agent
UnicodeEncodeError: 'gbk' codec can't encode character '\u274c' in position 0: illegal multibyte sequence
UnicodeEncodeError: 'gbk' codec can't encode character '\u274c' in position 0: illegal multibyte sequence
评论列表