1. 可以从 http://nginx.org/en/download.html 中下载 stable version 版本的 nginx
wget http://nginx.org/download/nginx-1.16.1.tar.gz
2. 解压 nginx 的安装包
tar -xzvf nginx-1.16.1.tar.gz
3. 在 nginx-1.16.1 目录下执行config命令
./configure --prefix=/home/bigdata/nginx
此过程最后可能会出现报错如下
./configure: error: C compiler cc is not found
解决方式是安装 gcc-c++
yum install gcc-c++
还可能报错如下
./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.
解决方法是安装 pcre-devel
yum install pcre-devel
还可能报错如下
./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.
解决方法是安装 zlib-devel
yum install zlib-devel
4. 在 nginx-1.16.1 目录下执行 make 编译
make
5. 在 nginx-1.16.1 目录下执行 make install
make install