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

Nginx启动失败:无法找到http-common.conf配置文件

Nginx启动失败问题解决

报错日志

× nginx.service - Nginx HTTP和反向代理服务器
     已加载:已加载(/usr/lib/systemd/system/nginx.service; 已启用; 预设:禁用)
    额外配置:/usr/lib/systemd/system/service.d
             └─10-timeout-abort.conf
     状态:失败(结果:退出码),自 周六 2023-07-29 09:53:30 WIB 起;4秒前
    进程:9182 ExecStartPre=/usr/bin/rm -f /run/nginx.pid(已退出,状态0/成功)
    进程:9188 ExecStartPre=/usr/sbin/nginx -t(已退出,状态1/失败)
        CPU:46ms

7月29日 09:53:30 xxxxxxx systemd[1]: 正在启动 nginx.service - Nginx HTTP和反向代理服务器...
7月29日 09:53:30 xxxxxxx nginx[9188]: nginx: [紧急错误] 打开"/etc/nginx/includes/http-common.conf"失败(2:无此文件或目录),位于/etc/nginx/conf.d/ds.conf:1
7月29日 09:53:30 xxxxxxx nginx[9188]: nginx: 配置文件/etc/nginx/nginx.conf测试失败
7月29日 09:53:30 xxxxxxx systemd[1]: nginx.service: 控制进程退出,代码=退出,状态1/失败
7月29日 09:53:30 xxxxxxx systemd[1]: nginx.service: 失败,结果为'exit-code'。
7月29日 09:53:30 xxxxxxx systemd[1]: 启动 nginx.service - Nginx HTTP和反向代理服务器失败。

核心错误原因

Nginx加载/etc/nginx/conf.d/ds.conf第1行时,无法找到/etc/nginx/includes/http-common.conf文件(错误码2:文件或目录不存在),导致配置文件测试不通过,最终服务启动失败。

解决步骤

  • 验证文件是否存在:执行命令 ls -l /etc/nginx/includes/http-common.conf,确认文件状态
  • 若文件不存在:
    • 若是自定义配置片段,手动创建该文件并添加所需配置内容
    • 若是Nginx默认配置文件,重新安装Nginx恢复缺失文件:
      • RHEL/CentOS系统:sudo dnf reinstall nginx
      • Debian/Ubuntu系统:sudo apt reinstall nginx
  • 若路径配置错误:编辑/etc/nginx/conf.d/ds.conf,修改第1行的include路径至正确位置
  • 修复后测试配置有效性:sudo nginx -t,确认输出显示配置测试成功
  • 测试通过后启动服务:sudo systemctl start nginx

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.15 00:22:47