1. 安装telnet
yum install -y telnet-server.x86_64
yum install -y telnet.x86_64
2. 安装gcc编译器
yum install -y gcc gcc-c++
3. 安装openssl
yum install -y openssl openssl-devel
4. 关闭防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service
5. 下载Nginx 以及相关依赖
推荐将Nginx 以及依赖的pcre和zlib下载到 /usr/local/ 目录下
- 到Nginx官网查看当前最新稳定版本
官方: https://nginx.org/
wget https://nginx.org/download/nginx-1.21.6.tar.gz
- 下载pcre
官方:https://sourceforge.net/projects/pcre/
wget https://nchc.dl.sourceforge.net/project/pcre/pcre/8.45/pcre-8.45.tar.gz
- 下载zlib
官方: http://www.zlib.net/
wget http://www.zlib.net/zlib-1.2.12.tar.gz
6. 安装pcre
tar -xzvf pcre-8.45.tar.gz
cd pcre-8.45
./configure
make
make install
7. 安装zlib
tar -xzvf zlib-1.2.12.tar.gz
cd zlib-1.2.12
./configure
make
make install
8. 安装Nginx
tar -xzvf nginx-1.21.6.tar.gz
cd nginx-1.21.6
./configure --prefix=/usr/local/nginx --with-pcre=/usr/local/pcre-8.45 --with-zlib=/usr/local/zlib-1.2.12 --with-http_sub_module --with-http_ssl_module --with-stream --with-http_v2_module --with-http_stub_status_module
make
make install
9. 启动Nginx
Nginx 已经安装在/usr/local/文件夹下的nginx目录下
退出 nginx-1.21.6文件夹, 进入nginx 目录
执行:
./sbin/nginx
10. 验证
通过查看进程和网络状态查看
ps -ef | grep nginx
netstat -nlp | grep nginx