环境

系统:centos7
nginx版本:1.12.2

nginx 下载地址:

https://nginx.org/download/

gzip模块需要 zlib 库

http://www.zlib.net/fossils/

rewrite模块需要 pcre 库

https://ftp.pcre.org/pub/pcre/

ssl 功能需要openssl库

https://www.openssl.org/source/

安装gcc

yum install gcc gcc-c++

下载

cd /opt/
wget https://nginx.org/download/nginx-1.12.2.tar.gz
wget https://ftp.pcre.org/pub/pcre/pcre-8.41.tar.gz
wget http://www.zlib.net/fossils/zlib-1.2.11.tar.gz
wget https://www.openssl.org/source/old/1.1.0/openssl-1.1.0f.tar.gz

解压

tar -zxvf nginx-1.12.2.tar.gz
tar -zxvf pcre-8.41.tar.gz
tar -zxvf zlib-1.2.11.tar.gz
tar -zxvf openssl-1.1.0f.tar.gz

开始安装

cd pcre-8.41/
./configure 
make && make install

cd ../zlib-1.2.11/
./configure 
make && make install

cd ../openssl-1.1.0f/
./config
make && make install

cd ../nginx-1.12.2/
./configure \
--prefix=/usr/local/nginx/ \
--with-http_stub_status_module \
--with-http_sub_module \
--with-http_gzip_static_module \
--with-pcre=../pcre-8.41 \
--with-zlib=../zlib-1.2.11 \
--with-openssl=../openssl-1.1.0f \
--with-http_secure_link_module \
--with-http_random_index_module \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_gzip_static_module \
--with-cc-opt=-O3 \
--with-http_gunzip_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_auth_request_module \
--with-threads \
--with-stream_ssl_module \
--with-http_slice_module \
--with-file-aio \
--with-http_v2_module \
--without-mail_pop3_module \
--without-mail_imap_module \
--without-mail_smtp_module

make && make install

启动服务

/usr/local/nginx/sbin/nginx