nginx的环境依赖说明

1.gcc的安装:安装 nginx 需要先将官网下载的源码进行编译,编译依赖 gcc 环境,如果没有 gcc 环境,则需要安装:

#CentOS:

yum install gcc-c++

#Ubuntu:
(以下选择一种)

1.    sudo apt-get -y install build-essential    #安装包含gcc c++编译器的包
2.    sudo apt-get -y install gcc    #安装gcc编译器

2.PCRE pcre-devel 安装:CRE(Perl Compatible Regular Expressions) 是一个Perl库,包括 perl 兼容的正则表达式库。nginx 的 http 模块使用 pcre 来解析正则表达式,所以需要在 linux 上安装 pcre 库,pcre-devel 是使用 pcre 开发的一个二次开发库。nginx也需要此库。

        未安装pcre库的报错

./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.

./configure: 错误:HTTP 重写模块需要 PCRE 库。
您可以使用 --without-http_rewrite_module 禁用该模块
选项,或者将 PCRE 库安装到系统中,或者构建 PCRE 库
使用 --with-pcre=<path> 选项从 nginx 的源静态地获取。

          解决办法

#CentOS:

yum install -y pcre pcre-devel

#Ubuntu:

sudo apt-get update
sudo apt-get -y install libpcre3 libpcre3-dev

3.zlib 安装:zlib 库提供了很多种压缩和解压缩的方式, nginx 使用 zlib 对 http 包的内容进行 gzip ,所以需要在 Centos 上安装 zlib 库。

        未安装zlib 库的报错

./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.

./configure: 错误:HTTP gzip 模块需要 zlib 库。
您可以使用 --without-http_gzip_module 禁用该模块
选项,或者将zlib库安装到系统中,或者构建zlib库
使用 --with-zlib=<path> 选项从 nginx 源静态地获取。

          解决办法

#CentOS:

yum install -y zlib zlib-devel

#Ubuntu:

sudo apt-get -y install zlib1g-dev

4.OpenSSL 安装:OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及 SSL 协议,并提供丰富的应用程序供测试或其它目的使用。nginx 不仅支持 http 协议,还支持 https(即在ssl协议上传输http),所以需要在 Centos 安装 OpenSSL 库。

        未安装OpenSSL 库的报错

./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.

./configure: 错误:SSL 模块需要 OpenSSL 库。
您可以不启用模块,也可以安装 OpenSSL 库
进入系统,或者从源代码静态构建 OpenSSL 库
通过使用 --with-openssl=<path> 选项与 nginx 一起使用。

         解决办法

#CentOS:

yum install -y openssl openssl-devel

#Ubuntu:

sudo apt-get -y install openssl libssl-dev

5.libraries库安装:

          未安装libraries库的报错

./configure: error: the HTTP XSLT module requires the libxml2/libxslt
libraries. You can either do not enable the module or install the libraries.

./configure: 错误:HTTP XSLT 模块需要 libxml2/libxslt
图书馆。 您可以不启用该模块或安装库。

         解决办法

#Ubuntu:

sudo apt-get -y install libxml2 libxml2-dev libxslt-dev
sudo apt-get -y install libgd2-xpm libgd2-xpm-dev

 6.GD库安装:

          未安装GD库的报错

./configure: error: the HTTP image filter module requires the GD library.
You can either do not enable the module or install the libraries.

./configure: 错误:HTTP 图像过滤器模块需要 GD 库。
您可以不启用该模块或安装库。

       解决办法

#CentOS:

yum install gd gd-devel

#Ubuntu:

sudo apt-get install -y libgd-dev

出现以下内容即安装完成

7.安装

 输入make 进行编译,编译完成出现以下界面则成功:

nginx deb依赖 nginx依赖环境_ubuntu

 输入make install安装,以下安装完成 

nginx deb依赖 nginx依赖环境_nginx_02