Redhat9(红帽9)离线安装nginx1.20.1(一)

最近由于公司的需要,要求新的应用内网服务器系统更新到Redhat9,就是红帽9,最新版。然后架构组成员就开始了红帽9的调研工作。从红帽9的中文官网了解到,该版本系统目前只有红帽企业 Linux 9正式版,RHEL 9 为支持混合云创新提供了更灵活、更稳定的基础,并为跨物理、虚拟、私有和公共云和边缘部署部署应用程序和关键工作负载提供了更快、更一致的体验。

经过一段时间的调研和学习之后,也开始正使用红帽9系统了。今天我先介绍一下红帽9上离线安装nginx服务器,将自己的实践操作整理成教程分享出来,供有需要的朋友参考学习。

1、环境准备

通常情况下,我们安装nginx所依赖的组件主要有以下几个,以及在红帽9上安装时对应的版本都整理如下:

Redhat9
gcc-11.2.1
g++-11.2.1
perl-5.32.1
pcre-8.44
zlib-1.2.11
openssl-3.0.1
nginx-1.20.1

这里我安装的nginx安装包版本为1.20.1。

2、特别说明

# 由于个别企业会使用Redhat或Centos最新系统,所以我们必须得进行组件和系统之间的适配。
# 本次适配系统为Redhat9。
# 系统兼容组件的官网说明地址:https://sysin.org/blog/rhel-9/和https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/9.0_release_notes/overview

3、安装

3.1、gcc离线安装
# 安装包以及依赖,需要大家提前准备好
gcc-11.2.1-9.4.el9.x86_64.rpm
cpp-11.2.1-9.4.el9.x86_64.rpm

# 安装命令
rpm -Uvh gcc-11.2.1-9.4.el9.x86_64.rpm --nodeps --force
rpm -Uvh cpp-11.2.1-9.4.el9.x86_64.rpm --nodeps --force
# 使用下面命令验证gcc安装是否成功,如果看到对应的版本信息,表示安装成功
gcc -v
3.2、yum安装perl
# Redhat9系统最小化安装后没有对应的perl,所以这里需要安装perl
# 安装方式俩种:yum安装和rpm安装
# 初次安装建议使用yum安装,因为安装perl时需要依赖的安装包特别多
# 本次我在内网中搭建了内网yum源
# 安装perl
dnf install perl 或 yum install -y perl
# 说明:perl安装成功后,会同时将g++、make等组件安装好,可以使用g++ -v命令测试。
3.3、g++安装
# 说明:上面的perl安装成功后,会同时将g++安装好,无需重复在安装。
# 输入g++ -v 命令测试即可
3.4、pcre-8.44离线安装
#上传pcre-8.44.tar.gz安装包至/home/www/apps/nginx目录  
# 检查是否安装pcre
[root@localhost ~]# rpm -qa pcre
[www@localhost nginx]# cd /home/www/apps/nginx
[www@localhost nginx]# tar -zxvf pcre-8.44.tar.gz
[www@localhost nginx]# rm pcre-8.44.tar.gz
[www@localhost nginx]# chmod -R 755 pcre-8.44
[www@localhost nginx]# cd pcre-8.44
[www@localhost pcre-8.44]# ./configure
[www@localhost pcre-8.44]# make
[www@localhost pcre-8.44]# make install
3.5、zlib-1.2.11离线安装
#上传zlib-1.2.11.tar.gz安装包至/home/www/apps/nginx目录  
[root@localhost ~]# rpm -qa zlib
[www@localhost nginx]# cd /home/www/apps/nginx
[www@localhost nginx]# tar -zxvf zlib-1.2.11.tar.gz
[www@localhost nginx]# rm zlib-1.2.11.tar.gz
[www@localhost nginx]# chmod -R 755 zlib-1.2.11
[www@localhost nginx]# cd zlib-1.2.11
[www@localhost zlib-1.2.11]# ./configure
[www@localhost zlib-1.2.11]# make
[www@localhost zlib-1.2.11]# make install
3.6、openssl-3.0.1离线安装
#上传openssl-3.0.1.tar.gz安装包至/home/www/apps/nginx目录  
[root@localhost ~]# rpm -qa zlib
[www@localhost nginx]# cd /home/www/apps/nginx
[www@localhost nginx]# tar -zxvf openssl-3.0.1.tar.gz
[www@localhost nginx]# rm openssl-3.0.1.tar.gz
[www@localhost nginx]# chmod -R 755 openssl-3.0.1
[www@localhost nginx]# cd openssl-3.0.1
[www@localhost openssl-3.0.1]# ./configure
[www@localhost openssl-3.0.1]# make
[www@localhost openssl-3.0.1]# make www
3.7、nginx-1.20.1
#上传nginx-1.20.1.tar.gz安装包至/home/www/apps/nginx目录  
[www@localhost nginx]# cd /home/www/apps/nginx
[www@localhost nginx]# tar -zxvf nginx-1.20.1.tar.gz
[www@localhost nginx]# rm nginx-1.20.1.tar.gz
[www@localhost nginx]# chmod -R 755 nginx-1.20.1
[www@localhost nginx]# cd nginx-1.20.1
# 同时编译的时候,解压目录要和安装目录分开!!!
[www@localhost nginx-1.20.1]# ./configure  --prefix=/home/www/apps/nginx/nginx --sbin-path=/home/www/apps/nginx/nginx/sbin/nginx  --conf-path=/home/www/apps/nginx/nginx/conf/nginx.conf  --pid-path=/home/www/apps/nginx/nginx/nginx.pid --with-http_ssl_module  --with-pcre=/home/www/apps/nginx/pcre-8.44 --with-zlib=/home/www/apps/nginx/zlib-1.2.11  --with-openssl=/home/www/apps/nginx/openssl-3.0.1
[www@localhost nginx-1.20.1]# make
[www@localhost nginx-1.20.1]# make install

nginx安装完成后,测试是否安装成功。

[www@localhost nginx-1.20.1]# cd /home/www/apps/nginx/sbin  
[www@localhost sbin]# ./nginx -v  

内容比较多,有什么问题可以评论留言。我们相互学习,一起成长。

# 红帽9官网:https://sysin.org/blog/rhel-9/
# 红帽9英文文档地址:
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/9.0_release_notes/overview

猜你喜欢

转载自blog.csdn.net/weixin_43672348/article/details/127217094