下载模块依赖性Nginx需要依赖下面3个包
- gzip 模块需要 zlib 库 ( 下载: http://www.zlib.NET/ )
- rewrite 模块需要 pcre 库 ( 下载: http://www.pcre.org/ )
- ssl 功能需要 openssl 库 ( 下载: http://www.openssl.org/ )
依赖包安装顺序依次为:openssl、zlib、pcre, 然后安装Nginx包
注意:如果报error: You need a C++ compiler for C++ support.
则安装yum install gcc-c++
openssl :
- tar -zxvf openssl-fips-2.0.16.tar.gz
- cd openssl-fips-2.0.16
- ./config && make && make install
pcre:
- tar -zxvf pcre-8.21.tar.gz
- cd pcre-8.21
- ./configure && make && make install
zlib:
- tar -zxvf zlib-1.2.7.tar.gz
- cd zlib-1.2.7
- ./configure && make && make install
nginx
- tar -zxvf nginx-1.12.1.tar.gz
- cd nginx-1.12.1
- ./configure --with-pcre=…/pcre-8.21/ --with-zlib=…/zlib-1.2.7/ --with-openssl=…/openssl-fips-2.0.16/ --prefix=/usr/local/tools/nginx (这是自定义安装目录)
- make
- make install
- cd /usr/local/nginx/sbin
- ./nginx -t 测试是否安装成功
- ./nginx 启动
- netstat -ntlp 查看监听端口
使用Linux yum安装方式
- 该方式非常简便使用名字会自动安装nginx相关依赖
yum install nginx #安装完成后目录在 /etc/nginx下