编译安装的四大步骤:
软件下载 -> 预编译 -> 编译 -> 配置
一、安装必备的编译工具:
yum install -y gcc gcc-c++ autoconf automake make
否则在预编译的过程中会报如下错误:
[root@localhost nginx]# ./configure
checking for OS
+ Linux 3.10.0-514.26.2.el7.x86_64 x86_64
checking for C compiler ... not found
./configure: error: C compiler cc is not found
二、安装pcre库,用来支持rewrite功能
yum install -y pcre-devel pcre
否则在预编译的过程中会出现以下问题:
checking for PCRE library ... not found
checking for PCRE library in /usr/local/ ... not found
checking for PCRE library in /usr/include/pcre/ ... not found
checking for PCRE library in /usr/pkg/ ... not found
checking for PCRE library in /opt/local/ ... not found
./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.
特别的:
在进行nginx编译安装的时候,Nginx需要整合pcre库,需要指定pcre源码目录,而不是pcre编译完成之后的路径,否则回报错
./configure --with-pcre=./auto/lib/pcre