1. rpm安装
$ yum install -y wget openssl
$ cd /opt
$ wget http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.10.0-1.el7.ngx.x86_64.rpm -O nginx-1.10.0-1.el7.ngx.x86_64.rpm
$ rpm -ivh nginx-1.10.0-1.el7.ngx.x86_64.rpm
$ rm -rf nginx-1.10.0-1.el7.ngx.x86_64.rpm && yum clean all
2. 源码编译安装
$ yum -y install gcc gcc-c++ make libtool zlib zlib-devel openssl openssl-devel pcre pcre-devel
$ cd /opt
$ wget http://nginx.org/download/nginx-1.10.1.tar.gz
$ tar -zxvf nginx-1.10.1.tar.gz
$ cd cd nginx-1.10.1
$ ./configure --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre
$ make && make install
3. dockerfile安装
3.1 rpm 安装
FROM centos
RUN yum install -y wget openssl &&\
cd /opt &&\
wget http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.10.0-1.el7.ngx.x86_64.rpm -O nginx-1.10.0-1.el7.ngx.x86_64.rpm &&\
rpm -ivh nginx-1.10.0-1.el7.ngx.x86_64.rpm &&\
rm -rf nginx-1.10.0-1.el7.ngx.x86_64.rpm &&\
yum clean all
3.2 源码安装
FROM centos
RUN yum install -y wget gcc gcc-c++ make libtool zlib zlib-devel openssl openssl-devel pcre pcre-devel &&\
yum clean all
RUN cd /opt &&\
wget http://nginx.org/download/nginx-1.10.1.tar.gz &&\
tar -zxvf nginx-1.10.1.tar.gz &&\
cd nginx-1.10.1 &&\
./configure --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre &&\
make && make install &&\
rm -rf /opt/nginx-1.10.1*
ENV NGINX_HOME=/usr/local/webserver/nginx
ENV PATH=$NGINX_HOME/sbin:$PATH
参考
https://segmentfault.com/a/1190000007116797