1.下载
在nginx官网http://nginx.org/en/download.html下载文档版本的源码,编译安装到/opt/nginx
wget http://nginx.org/download/nginx-1.12.1.tar.gz
2.解压
tar -zxvf nginx-1.12.1.tar.gz
3.安装依赖
避免编译报错,先yum安装一些依赖库
yum install gcc -y
yum install pcre-devel -y
yum install openssl openssl-devel -y
yum install zlib-devel -y
yum install compat-libstdc++-33 -y
yum install libfreetype.i686 -y
yum install libXext.x86_64 -y
4.编译
cd nginx-1.12.1
./configure \
--prefix=/opt/nginx \
--with-http_realip_module \
--with-http_sub_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-stream \
--with-pcre
make
make install