You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu 22.04启动Nginx报‘unknown directive brotli’错误求解决

解决Nginx启动时"unknown directive 'brotli'"错误的方案

这个错误的核心原因是当前Nginx未加载Brotli压缩模块——Brotli不是Nginx默认内置的功能,需要单独安装并加载模块。以下是针对Ubuntu 22.04环境的具体解决步骤:

情况1:通过Ubuntu官方源安装的Nginx

  • 安装Brotli模块包:
    sudo apt update && sudo apt install nginx-module-brotli
    
  • 编辑Nginx主配置文件/etc/nginx/nginx.conf,在http块之前添加模块加载指令:
    load_module modules/ngx_http_brotli_filter_module.so;
    load_module modules/ngx_http_brotli_static_module.so;
    
  • 验证配置合法性并重启Nginx:
    sudo nginx -t && sudo systemctl restart nginx
    

情况2:Plesk自带的Nginx

如果你的Nginx是Plesk集成安装的,需通过Plesk工具安装模块:

  • 执行模块安装命令:
    sudo plesk installer add --components nginx-brotli
    
  • 重启Nginx服务:
    sudo systemctl restart nginx
    

临时应急方案(不推荐长期使用)

如果需要先临时启动Nginx,可以注释掉brotli.conf中的配置:

  • 编辑/etc/nginx/conf.d/brotli.conf,将内容修改为:
    # brotli on;
    # brotli_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
    
  • 验证并重启:
    sudo nginx -t && sudo systemctl restart nginx
    

内容的提问来源于stack exchange,提问作者Pepe26

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 19:22:40