nginx 编译错误 the HTTP gzip module requires the zlib library
问题描述
下载 nginx 源代码,并安装,运行以下命令。
$ wget http://nginx.org/download/nginx-1.19.1.tar.gz
$ tar xf nginx-1.19.1.tar.gz
$ cd nginx-1.19.1
$ ./configure --prefix=/opt/nginx
但是最后报错了。
checking for zlib library ... not found
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib= option.
解决方法
需要安装 zlib-devel
,可以手动安装或者命令行安装。
1. 手动安装
在 https://pkgs.org/search/?q=zlib 页面中,找到与操作系统相对应的 zlib-devel
版本,并下载安装。
2. 命令行安装
Ubuntu/Debian
sudo apt-get install zlib1g-dev
RHEL/CentOS
sudo yum install zlib-devel