“bash: make: command not found”最常见原因是未安装make工具本身,需根据系统安装对应开发包:ubuntu/debian执行sudo apt install build-essential,centos/rhel执行sudo yum groupinstall "development tools",macos执行xcode-select --install。

直接看报错里有没有 “no make”、“command not found: make” 或者 “No rule to make target” 但前面没生成 Makefile,基本就是没装 make 工具本身,不是依赖库的问题。
确认 make 是否真的没装
在终端执行:
- make --version —— 如果提示 command not found,说明 make 完全缺失
- which make —— 返回空,也证实未安装
安装基础编译工具链
单独装 make 往往不够,因为 Nginx 编译还需要 gcc、autoconf、perl 等。推荐一次性装全开发环境:
- Anolis/CentOS/RHEL 系: sudo yum groupinstall "Development Tools"
- Ubuntu/Debian 系: sudo apt update && sudo apt install build-essential
装完再运行 make --version 和 gcc --version 验证是否就绪。
注意区分“没 make”和“Makefile 不完整”
这两类问题表现相似,但根源不同:
-
真没 make:执行
make命令时系统直接报找不到命令,./configure可能都还没跑或静默失败 -
有 make 但报 “No rule to make target 'build'”:说明
make存在,但./configure因缺少 pcre-devel、zlib-devel、openssl-devel 等导致生成的 Makefile 缺关键规则
所以看到报错,先查 make 本身是否存在,再看 configure 是否成功输出 configuration finished。
检查 configure 执行结果
./configure 是生成 Makefile 的前提。如果它中途退出或最后没打印成功提示,就别急着 make:
- 执行后立刻运行 echo $? —— 返回 0 才算成功
- 查看当前目录是否有 Makefile 文件:ls -l Makefile
- 若没有 Makefile,翻看 config.log,搜索 error 或 not found,定位具体缺哪个依赖











