一、安装前准备
nginx安装需要依赖库zlib、openssl、pcre,所以在安装nginx时,它们需要先安装。
下载以下安装包:
ssl功能需要openssl库:openssl-fips-2.0.16.tar.gz ,地址:https://www.openssl.org/source/
rewrite模块需要pcre库:pcre-8.41.tar.gz (正则表达式库),地址:https://sourceforge.net/projects/pcre/files/pcre/
gzip模块需要zlib库:zlib-1.2.11.tar.gz,地址:http://www.zlib.net/
nginx-1.12.2.tar.gz ,地址:http://nginx.org/en/download.html
二.、在服务器usr/local/src下新建nginx目录,上传安装包,如图所示:
三、安装
##安装openssl
tar openssl-fips-2.0.16.tar.gz
cd openssl-fips-2.0.16 #prefix配置安装路径,这里不用配置默认安装目录在当前 ./config make make install
##安装pcre tar -zxvf pcre-8.41.tar.gz cd pcre-8.41 ./configure make make install
##安装zlib tar -zxvf zlib-1.2.11.tar.gz cd zlib-1.2.11 ./configure make make install
##安装nginx tar -zxvf nginx-1.12.2.tar.gz cd nginx-1.12.2 #with-pcre指定依赖包位置,prefix配置安装路径 ./configure --with-pcre=../pcre-8.41 --with-zlib=../zlib-1.2.11 --with-openssl=../openssl-fips-2.0.16 --prefix=/usr/local/nginx make make install
进入/usr/local/nginx目录,可以看到安装的内容:
至此,nginx安装完成。
四、测试,cd /usr/local/nginx/sbin 目录
成功启动nginx。