在线安装
安装依赖包
yum -y install gcc gcc-c++ autoconf automake
yum -y install pcre pcre-devel
yum -y install zlib zlib-devel
yum -y install openssl opnessl-devel
下载编译Nginx
cd /usr/local/src
wget http://nginx.org/download/nginx-1.16.1.tar.gz
tar -zxvf nginx-1.16.1.tar.gz
./configure
make
make install
服务启停
whereis nginx
cd /usr/local/nginx
cd sbin
nginx //启动nginx
nginx -s reload //重新载入配置文件
nginx -s reopen //重启nginx
nginx -s stop //停止nginx
离线安装
下载Nginx依赖包
依赖包安装顺序依次为:openssl,zlib,pcre,最后安装 Nginx 包
安装OpenSSL
[root@localhost wcw]# tar -zxvf openssl-fips-2.0.2.tar.gz
[root@localhost wcw]# cd openssl-fips-2.0.2
[root@localhost openssl-fips-2.0.2]# ./config
[root@localhost openssl-fips-2.0.2]# make
[root@localhost openssl-fips-2.0.2]# make install
安装zlib
[root@localhost wcw]# tar -zxvf zlib-1.2.7.tar.gz
[root@localhost wcw]# cd zlib-1.2.7
[root@localhost zlib-1.2.7]# ./configure
[root@localhost zlib-1.2.7]# make
[root@localhost zlib-1.2.7]# make install
安装pcre
[root@localhost wcw]# tar -zxvf pcre-8.21.tar.gz
[root@localhost wcw]# cd pcre-8.21
[root@localhost pcre-8.21]# ./configure
[root@localhost pcre-8.21]# make
[root@localhost pcre-8.21]# make install
安装Nginx
[root@localhost wcw]# tar -zxvf nginx-1.12.2.tar.gz
[root@localhost wcw]# cd nginx-1.12.2
[root@localhost nginx-1.12.2]# ./configure --prefix=/usr/install/nginx --with-pcre=../pcre-8.21 --with-zlib=../zlib-1.2.7 --with-openssl=../openssl-fips-2.0.2
[root@localhost nginx-1.12.2]# make
[root@localhost nginx-1.12.2]# make install