手动安装Nginx报错

checking for C compiler … not found

报错:

1
2
3
4
5
6
root@Test-Learn:~/learn/nginx-1.22.0# ./configure
checking for OS
+ Linux 5.19.0-15-generic x86_64
checking for C compiler ... not found

./configure: error: C compiler cc is not found

解决:apt install -y gcc g++

PCRE library

报错:

1
2
3
4
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

解决:

  • debain apt install -y libpcre3 libpcre3-dev
  • centos:yum install pcre pcre-devel

zlib library

报错:

1
2
3
4
./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=<path> option.

解决:

  • debain apt install -y zlib1g zlib1g-dev
  • centos:yum install zlib zlib-devel

missing make

报错:

1
2
3
4
root@Test-Learn:~/learn/nginx-1.22.0# make
Command 'make' not found, but can be installed with:
apt install make # version 4.3-4.1build1, or
apt install make-guile # version 4.3-4.1build1

解决:apt install -y make

nginx: [emerg] unknown directive “ssl”

首先先关闭nginx

解决:不存在ssl模块,重新解压编译ssl模块

  1. 查看原有模块:/usr/local/nginx/sbin/nginx -V

  2. 重新编写配置信息,在原有模块之后增加:--with-http_ssl_module

    示例:./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module

  3. make -> 之后不要执行install

  4. 备份原有Nginx

  5. 复制编译的新nginx(obj目录里)到原来位置