nginx搭建

1、下载源包

需要安装 pcre、openssl、zlib

2、解压缩

上传文件到 /usr/tools/ 目录

1
2
3
4
5
6
7
8
tar -zxvf nginx-1.20.1.tar.gz
tar -zxvf pcre-8.45.tar.gz
tar -zxvf openssl-3.0.0.tar.gz
tar -zxvf zlib-1.2.11.tar.gz
mv nginx-1.20.1 nginx
mv pcre-8.45.tar.gz pcre
mv openssl-3.0.0 openssl
mv zlib-1.2.11 zlib

3、编译源码

安装 pcre

1
2
3
4
yum -y install gcc-c++ #先安装编译器,已经安装可以跳过
cd /usr/tools/pcre/
./configure
make & make install

安装openssl

可先检查有没有openssl

1
2
3
4
5
openssl version # 有则不需要安装
# 没有的话
cd /usr/tools/openssl/
./config
make & make install

安装 zlib

1
2
3
cd /usr/tools/zlib/
./configure
make & make install

安装 nginx

1
2
3
4
5
cd /usr/tools/nginx/
which openssl #查找 openssl 安装位置
# 配置 nginx ,准备安装
./configure --with-pcre=../pcre --with-zlib=../zlib --with-openssl=/usr/bin/openssl
make & make install