fenglei7093

博客园 首页 新随笔 联系 订阅 管理

软件管理

不同系统软件包定义

linux软件的类型

rpm软件 *.rpm
源码软件 *.tar.gz, *.tar.bz2
源码软件的优点:灵活性强,可自由定义其功能,这也是Linux系统飞速发展的一个根本原因 。

Linux应用程序的软件包按内容类别可分为两类:

1.rpm可执行文件(编译后的二进制软件包)

解开包后就可以直接运行的。在Windows中所有的软件包都是这种类型。安装完这个程序后,你就可以使用,但你看不到源程序。
而且下载时要注意这个软件是否是你所使用的平台,否则将无法正常安装。

优点:使用简单,只需要几个命令就可以实现包的安装、升级、查询、卸载;安装速度快;

缺点:不能看源代码;功能选择不如源代码灵活;依赖性;

2.源程序(源码包,需要使用编译器进行编译才能使用)

解开包后,你还需要使用编译器将其编译成为可执行文件。这在Windows系统中是几乎没有的,
因为Windows的思想是不开放源程序的。

优点:开源;可以自由选择所需功能;可看源代码;卸载方便(直接删除安装位置);

缺点:安装步骤过多;编译时间过长;

3.区别

几乎所有的Linux发行版本都使用某种形式的软件包管理安装、更新和卸载软件。
与直接从源代码安装相比,软件包管理易于安装和卸载;易于更新已安装的软件包;
易于保护配置文件;易于跟踪已安装文件。  

通常,用tar打包的,都是源程序;而用rpm、dpkg打包的则常是可执行程序。
一般来说,自己动手编译源程序能够更具灵活性,但也容易遇到各 种问题和困难。
而相对来说,下载那些可执行程序包,反而是更容易完成软件的安装,当然那样灵活性就差多了。
所以一般一个软件总会提供多种打包格式的安装程序的。你可以根据自己的情况来选择。 

1.rpm软件安装包名称的组成

liunx系统中可访问的所有文件都排列在一棵大树中,即文件层次结构,根在/。这些文件可以分布在多个设备上。mount命令用于将某些设备上的文件系统附加到大文件树。相反,umount命令将再次将其分离。

在学会安装rpm软件前我们需要了解下“挂载”这个概念

挂载概念

Linux中的根目录以外的文件要想被访问,需要将其“关联”到根目录下的某个目录来实现,这种关联操作就是“挂载”,这个目录就是“挂载点”,解除次关联关系的过程称之为“卸载”

注意:“挂载点”的目录需要以下几个要求:

(1)目录事先存在,可以用mkdir命令新建目录;

(2)挂载点目录不可被其他进程使用到;

(3)挂载点下原有文件将被隐藏。

mount:通过查看/etc/mtab(文章最后会对/etc/mtab有个解释)文件显示当前系统已挂载的所有设备

查看最近一次的挂载设备
[root@localhost ~]# tail -1 /etc/mtab
/dev/sr0 /var/ftp/centos7.5 iso9660 ro,relatime 0 0

如何获取光盘镜像中的软件
[root@localhost ~]# mkdir /mnt (事先创造挂载点。默认文件类型)
[root@localhost dev]# mount /dev/sr0 /mnt
mount: /dev/sr0 写保护,将以只读方式挂载
/dev/sr0 : 挂载设备
/dir : 挂载点

[root@localhost dev]# ls /dir
CentOS_BuildTag EFI EULA GPL images isolinux LiveOS Packages repodata RPM-GPG-KEY-CentOS-7 RPM-GPG-KEY-CentOS-Testing-7 TRANS.TBL

文件系统类型的查看(硬盘)
[root@VM-0-10-centos /]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 989M 0 989M 0% /dev
tmpfs tmpfs 1000M 24K 1000M 1% /dev/shm
tmpfs tmpfs 1000M 468K 999M 1% /run
tmpfs tmpfs 1000M 0 1000M 0% /sys/fs/cgroup
/dev/vda1 ext4 40G 3.6G 34G 10% /
tmpfs tmpfs 200M 0 200M 0% /run/user/0

type : 文件系统类型

mount [选项] 设备 挂载目录
-t 文件类型

mount -t /文件系统类型/ /挂载点/ 指定要挂载的设备上的文件系统类型

大多数Linux应用软件包的命名也有一定的规律,他遵循:名称-版本-修正版-类型
zlib-1.2.7-15.el7.x86_64.rpm >>>软件安装包名称

1)software-1.2.3-1.tar.gz 意味着:

软件名称:software

版本号:1.2.3

修正版本:1

类型:tar.gz,说明是个tar包。

2)sfotware-1.2.3-1.i386.rpm

软件名称:software

版本号:1.2.3

修正版本:1

可用平台:i386,适用于Intel 80x86平台。

类型:rpm,说明是个rpm包。

2.如何获取到rpm

(1)系统安装光盘

[root@VM-0-10-centos /]# ll /dev/sr0
brw-rw---- 1 root cdrom 11, 0 Feb 26 14:59 /dev/sr0
[root@VM-0-10-centos /]# ll /dev/cdrom
lrwxrwxrwx 1 root root 3 Feb 26 14:59 /dev/cdrom -> sr0

/cdrom 该目录在刚安装系统时是空的,你可以将光驱文件系统挂在这个目录下。
例如:mount /dev/cdrom /cdrom

方法一:

mount /dev/cdrom /mnt -----------虚拟机挂载设备

ls /mnt/Packages

方法二:
1. 先上传镜像文件 (新建文件传输)
[root@localhost /]# ls
aa bin boot CentOS-7-x86_64-Minimal-1708.iso dev dira etc home lib lib64 media mnt opt proc root run sbin software srv sys tmp user55 usr var

[root@localhost /]# mount -t CentOS-7-x86_64-Minimal-1708.iso /qf/
mount: 在 /etc/fstab 中找不到 /qf/

可知在/etc/fstab找不到要挂载的文件

/etc/fstab是用来存放文件系统的静态信息的文件。位于/etc/目录下,可以用命令less /etc/fstab 来查看,如果要修改的话,则用命令 vi /etc/fstab 来修改。当系统启动的时候,系统会自动地从这个文件读取信息,并且会自动将此文件中指定的文件系统挂载到指定的目录。

其中有两种解决方式:
1.输入命令:mount -t iso9660 /dev/cdrom /mnt/cdrom
其中/dev/cdrom为软连接指向的是hdc即是镜像文件的挂载盘
这时候在输入命令:ls -l /mnt/cdrom 敲击enter键显示的是你要挂载的iso文件里的所有文件,到此成功挂载镜像

[root@localhost ~]# mount -t iso9660 /dev/cdrom /qf/
mount: /dev/sr0 写保护,将以只读方式挂载
[root@localhost ~]# ll /qf/
总用量 686
-rw-rw-r--. 1 root root 14 11月 26 2018 CentOS_BuildTag
drwxr-xr-x. 3 root root 2048 11月 26 2018 EFI
-rw-rw-r--. 1 root root 227 8月 30 2017 EULA
-rw-rw-r--. 1 root root 18009 12月 10 2015 GPL
drwxr-xr-x. 3 root root 2048 11月 26 2018 images
drwxr-xr-x. 2 root root 2048 11月 26 2018 isolinux
drwxr-xr-x. 2 root root 2048 11月 26 2018 LiveOS
drwxrwxr-x. 2 root root 663552 11月 26 2018 Packages
drwxrwxr-x. 2 root root 4096 11月 26 2018 repodata
-rw-rw-r--. 1 root root 1690 12月 10 2015 RPM-GPG-KEY-CentOS-7
-rw-rw-r--. 1 root root 1690 12月 10 2015 RPM-GPG-KEY-CentOS-Testing-7
-r--r--r--. 1 root root 2883 11月 26 2018 TRANS.TBL

[root@localhost ~]# ls /qf/
CentOS_BuildTag GPL LiveOS RPM-GPG-KEY-CentOS-7
EFI images Packages RPM-GPG-KEY-CentOS-Testing-7
EULA isolinux repodata TRANS.TBL

[root@localhost ~]# df -Th
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/sda3 xfs 100G 6.5G 93G 7% /
devtmpfs devtmpfs 895M 0 895M 0% /dev
tmpfs tmpfs 910M 0 910M 0% /dev/shm
tmpfs tmpfs 910M 11M 900M 2% /run
tmpfs tmpfs 910M 0 910M 0% /sys/fs/cgroup
/dev/sda1 xfs 397M 162M 235M 41% /boot
tmpfs tmpfs 182M 32K 182M 1% /run/user/0
/dev/sr0 iso9660 4.3G 4.3G 0 100% /mnt
/dev/loop0 iso9660 792M 792M 0 100% /qf

2.修改/etc/fstab文件
首先编辑文件fstab命令:vi /etc/fstab
在文件里追加一行内容:/dev/cdrom /mnt/cdrom iso9660 defaluts 0 0
然后在/root目录下:mkdir /mnt/cdrom
执行命令:mount /mnt/cdrom
到此成功挂载镜像

(2)查看挂载方式:
[root@localhost ~]# mount | tail -3
/dev/sr0 on /mnt type iso9660 (ro,relatime,uid=0,gid=0,iocharset=utf8,mode=0400,dmode=0500)
/dev/sr0 on /qf type iso9660 (ro,relatime,uid=0,gid=0,iocharset=utf8,mode=0400,dmode=0500)
/CentOS-7-x86_64-Minimal-1708.iso on /qf type iso9660 (ro,relatime)

(3)卸载挂载
[root@localhost mnt]# df -Th
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/sda3 xfs 100G 6.5G 93G 7% /
devtmpfs devtmpfs 895M 0 895M 0% /dev
tmpfs tmpfs 910M 0 910M 0% /dev/shm
tmpfs tmpfs 910M 11M 900M 2% /run
tmpfs tmpfs 910M 0 910M 0% /sys/fs/cgroup
/dev/sda1 xfs 397M 162M 235M 41% /boot
tmpfs tmpfs 182M 32K 182M 1% /run/user/0
/dev/sr0 iso9660 4.3G 4.3G 0 100% /mnt
/dev/loop0 iso9660 792M 792M 0 100% /qf

[root@localhost mnt]# umount /dev/loop0

[root@localhost mnt]# df -Th
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/sda3 xfs 100G 6.5G 93G 7% /
devtmpfs devtmpfs 895M 0 895M 0% /dev
tmpfs tmpfs 910M 0 910M 0% /dev/shm
tmpfs tmpfs 910M 11M 900M 2% /run
tmpfs tmpfs 910M 0 910M 0% /sys/fs/cgroup
/dev/sda1 xfs 397M 162M 235M 41% /boot
tmpfs tmpfs 182M 32K 182M 1% /run/user/0
/dev/sr0 iso9660 4.3G 4.3G 0 100% /qf

3.使用rpm命令管理rpm软件

(1)安装rpm软件
前提:所安装的软件能够找到

rpm -ivh <软件安装包名称>

-i 安装
-v 检测套件是否正确安装
-h 显示#百分比
-p 显示安装进度
-U 升级安装
-e 卸载

示例:安装dhcp软件

[root@test01 ~]# rpm -ivh /mnt/Packages/dhcp-4.2.5-42.el7.centos.x86_64.rpm
警告:/mnt/Packages/dhcp-4.2.5-42.el7.centos.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:dhcp-12:4.2.5-42.el7.centos ################################# [100%]

示例:安装httpd软件
[root@test01 ~]# rpm -ivh --nodeps /mnt/Packages/httpd-2.4.6-40.el7.centos.x86_64.rpm
警告:/mnt/Packages/httpd-2.4.6-40.el7.centos.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:httpd-2.4.6-40.el7.centos ################################# [100%]

[root@localhost ~]# ls
autocorr-zh-5.3.6.1-25.el7_9.noarch.rpm dira 公共 模板 视频 图片 文档 下载 音乐 桌面

2) 查看rpm软件

(1) 查询httpd软件是否安装

[root@test01 ~]# rpm -q httpd
httpd-2.4.6-40.el7.centos.x86_64

[root@test01 ~]# rpm -qa | grep vim
vim-enhanced-7.4.160-1.el7.x86_64
vim-minimal-7.4.160-1.el7.x86_64
vim-filesystem-7.4.160-1.el7.x86_64
vim-common-7.4.160-1.el7.x86_64

[root@wyy ~]# rpm -qa -- 查询目前所有安装的软件

(2) 查询httpd软件生成的文件

rpm -ql <软件名称>

[root@test01 ~]# rpm -ql httpd | less

(3) 查询某个文件由哪个软件生成

[root@test01 ~]# which ifconfig
/usr/sbin/ifconfig

[root@test01 ~]# rpm -qf /usr/sbin/ifconfig
net-tools-2.0-0.17.20131004git.el7.x86_64

[root@www /]# which ls
alias ls='ls --color=auto'
/usr/bin/ls
[root@www /]# rpm -qf /usr/bin/ls
coreutils-8.22-11.el7.x86_64
[root@www /]# rpm -ql coreutils
/etc/DIR_COLORS

[root@www /]# which ip
/usr/sbin/ip
[root@www /]# rpm -qf /usr/sbin/ip
iproute-3.10.0-13.el7.x86_64

(4) rpm -qc 查看软件包生成的配置文件

[root@localhost ~]# rpm -qc dhcp
/etc/dhcp/dhcpd.conf
/etc/dhcp/dhcpd6.conf
/etc/openldap/schema/dhcp.schema
/etc/sysconfig/dhcpd
/var/lib/dhcpd/dhcpd.leases

[root@wyy Packages]# rpm -ivh httpd-2.4.6-88.el7.centos.x86_64.rpm --nodeps --force
警告:httpd-2.4.6-88.el7.centos.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:httpd-2.4.6-88.el7.centos ################################# [100%]

选项:
--nodeps 忽略依赖关系
--force 强制重新安装

yum方式管理软件包

优势:自动解决软件的依赖关系
前提:配置yum源仓库
yum源类型:

本地源: baseurl=file:///software
ftp源: baseurl=ftp://172.16.8.100/centos7u2
网络源: http源 baseurl=https://mirrors.aliyun.com/centos/7.3.1611/storage/x86_64/gluster-3.7/ (联网的情况下)

yum源配置文件:
/etc/yum.repos.d/*.repo
内容说明:
[base] 标签名称,一定要放在[]中
name 容器说明,可以自己随便写
mirrorlist 镜像站点,这个可以注释掉
baseurl yum源服务器的地址,默认是CentOS官方的yum源服务器。
enable 此容器是否生效,如果不写或者写成enable=1都是生效,写成enable=0 表示失效
gpgcheck 如果是1指RPM的数字证书生效,如果是0则不生效(一般都是写0)
gpgkey 数字证书的公钥文件保存位置,不用修改

示例:配置本地yum源

解决: 没有网络情况下在本地可以安装软件

[root@localhost ~]# mkdir /rpms ---本地挂载点
[root@localhost ~]# mount /dev/sr0 /rpms/ ---挂载设备到挂载点
mount: /dev/sr0 写保护,将以只读方式挂载
[root@localhost ~]# df -Th
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/sda3 xfs 100G 6.5G 93G 7% /
devtmpfs devtmpfs 895M 0 895M 0% /dev
tmpfs tmpfs 910M 0 910M 0% /dev/shm
tmpfs tmpfs 910M 11M 900M 2% /run
tmpfs tmpfs 910M 0 910M 0% /sys/fs/cgroup
/dev/sda1 xfs 397M 162M 235M 41% /boot
tmpfs tmpfs 182M 32K 182M 1% /run/user/0
/dev/sr0 iso9660 4.3G 4.3G 0 100% /rpms

[root@www /]# mkdir /etc/yum.repos.d/bak
[root@www /]# mv /etc/yum.repos.d/CentOS-* /etc/yum.repos.d/bak/(把原来的yum配置文件移动到新建目录)----防止后续列出yum源内容出错

[root@localhost ~]# vim /etc/yum.repos.d/localyum.repo (编写yum源配置文件)

[centos-7]
name=yum
baseurl=file:///rpms
enable=1
gpgcheck=0

[root@localhost ~]# yum clean all ---清除缓存
已加载插件:fastestmirror, langpacks
/var/run/yum.pid 已被锁定,PID 为 12296 的另一个程序正在运行。
Another app is currently holding the yum lock; waiting for it to exit...

[root@localhost ~]# yum makecache ---加载缓存
已加载插件:fastestmirror, langpacks
Determining fastest mirrors
* AppStream: mirrors.aliyun.com
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com

[root@localhost ~]# yum repolist ---列出yum源内容
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* AppStream: mirrors.aliyun.com
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
源标识 源名称 状态
7 yum 4,021
AppStream/x86_64 CentOS-8.5.2111 - AppStream - mirrors.aliyun.com 6,533
base/x86_64 CentOS-8.5.2111 - Base - mirrors.aliyun.com 1,898
extras/x86_64 CentOS-8.5.2111 - Extras - mirrors.aliyun.com 38
repolist: 12,490

常用的yum用法 :

1.安装软件

yum install -y <软件名称>

2.卸载软件

yum remove -y <软件名称>

3.升级软件

yum update -y <软件名称> (版本较高的文件)

4.列出yum源仓库中所有软件

yum list all

5.查询软件的信息

[root@test01 ~]# yum info httpd

已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
可安装的软件包
名称 :httpd
架构 :x86_64
版本 :2.4.6
发布 :40.el7.centos
大小 :2.7 M
源 :local
简介 : Apache HTTP Server
网址 :http://httpd.apache.org/
协议 : ASL 2.0
描述 : The Apache HTTP Server is a powerful, efficient, and extensible
: web server.

6.查看某个文件由哪个软件生成

[root@test01 ~]# yum provides "*/lftp"
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
lftp-4.4.8-7.el7.x86_64 : A sophisticated file transfer program
源 :local
匹配来源:
文件名 :/usr/bin/lftp
文件名 :/usr/lib64/lftp

* 通配符

使用yum管理软件组

1) 列出软件组

[root@test01 ~]# yum grouplist

2) 安装一组软件

yum groupinstall -y <软件组名称>

yum groupremove -y <软件组名称>

常见的yum源地址

扩展源: 因为在官方源或者本地(镜像中)有的软件包不存在(不完整),在使用epel源,需要先配置网络源

配置网络源:
1、手动自己写好配置文件(比较麻烦)
2、直接使用写好的源

1.EPEL yum 源: http://fedoraproject.org/wiki/EPEL 扩展源

方法一:
# rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

方法二:

yum install -y epel-release

注意:使用其他网络源的时候需要补充/centos/$releasever/os/$basearch/内容到文件连接后。
2、阿里yum 源 : http://mirrors.aliyun.com/

3、suhu yum 源 http://mirrors.sohu.com/centos/7/os/x86_64/

4、163 yum 源 http://mirrors.163.com/centos/7/

知名企业yum源地址:

搜狐开源镜像站:http://mirrors.sohu.com/

网易开源镜像站:http://mirrors.163.com/

常用yum源镜像地址
阿里巴巴开源镜像站

https://opsx.alibaba.com/mirror/

http://mirrors.aliyun.com/centos/
网易开源镜像站

http://mirrors.163.com/
Centos社区镜像站

http://mirror.centos.org/centos/
sohu开源镜像站

http://mirrors.sohu.com/help/
中科大开源镜像站(中国官方镜像站)

http://centos.ustc.edu.cn/
上海交通大学开源软件镜像站

http://ftp.sjtu.edu.cn/
北京理工大学 开源软件镜像站

http://mirror.bit.edu.cn/web/
北京交通大学自由与开源软件镜像站

https://mirror.bjtu.edu.cn/
兰州大学开源社区镜像站

https://mirror.lzu.edu.cn/
清华大学开源软件镜像站

https://mirrors.tuna.tsinghua.edu.cn/
江苏开放大学开源软件镜像站

http://mirrors.jstvu.edu.cn/
大连理工大学开源镜像站

http://mirror.dlut.edu.cn/
淡江大学伺服器(台湾)

http://ftp.tku.edu.tw/
國立暨南國際大學檔案伺服器(台湾)

http://ftp.ncnu.edu.tw/
Nginx-yum源

http://nginx.org/packages/
mysql-yum源

https://repo.mysql.com/yum
红帽镜像:

https://developers.redhat.com/products/
Centos 镜像

https://www.centos.org/download/
Ubuntu镜像

https://www.ubuntu.com/download/desktop
Deepin镜像

https://www.deepin.org/mirrors/packages/
fedora镜像

https://getfedora.org/en/server/download/
Windows镜像

https://msdn.itellyou.cn/

配置网络源:
1. 配置阿里、163等源
2. epel源

扩展:

环境介绍: 2台服务器
使用的桥接模式
ftp server: 10.7.189.150 提供镜像文件
yum client: 10.7.189.145

1.操作之前两台服务器先关闭防火墙和selinux
[root@localhost ~]# iptables -F 清空防火墙规则
[root@localhost ~]# iptables -L 列出防火墙规则
Chain INPUT (policy ACCEPT)
target prot opt source destination

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

Chain FORWARD_IN_ZONES (0 references)
target prot opt source destination

[root@localhost ~]# setenforce 0 临时关闭selinux
[root@localhost ~]# getenforce 查看selinux状态
Permissive (中译:宽容的,放任的,允许而非强制的)

一、配置ftp源

1. 安装ftp服务(ftp server端)
# yum install -y vsftpd

2. 启动ftp服务
# systemctl start vsftpd

3. 验证服务是否成功
# ss -antp | grep vsftpd
LISTEN 0 32 :::21 ::😗 users:(("vsftpd",pid=9408,fd=4))

4.镜像文件放到ftp的服务器上(可以挂载使用光驱)
方法一:
上传镜像文件

方法二:
挂载已有的光驱设备

5.挂载镜像到ftp对外提供服务的目录里
挂载前下载wegt:

[root@localhost ~]# yum install -y wget
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
软件包 wget-1.14-18.el7_6.1.x86_64 已安装并且是最新版本
无须任何处理

二、配置client端

6. 写yum配置文件(在yum client 端)

[root@localhost ~]# vim /etc/yum.repos.d/ftp.repo

[Centos7.2]
name=Centos7.2
baseurl=ftp://10.7.189.150/centos7.6/ ----路径一定要跟ftp源相同
enabled=1
gpgcheck=0

[root@localhost ~]# yum clean all
已加载插件:fastestmirror
正在清理软件源: Centos7.2 base extras updates
Cleaning up list of fastest mirrors

[root@localhost ~]# yum repolist
已加载插件:fastestmirror
Determining fastest mirrors
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
源标识 源名称 状态
Centos7.2 Centos7.2 0
base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com 10,072
extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com 519
updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 5,766
repolist: 16,357

测试ftp服务是否能够正常使用:

[root@wyy yum.repos.d]# yum install -y lftp
[root@wyy yum.repos.d]# lftp 10.7.189.122
lftp 10.7.189.122:~> ls
drwxrwxr-x 8 0 0 2048 Nov 25 2018 centos7.6
drwxr-xr-x 2 0 0 6 Jun 09 2021 pub
lftp 10.7.189.122:/> cd centos7.6/
lftp 10.7.189.122:/centos7.6> ls
-rw-rw-r-- 1 0 0 14 Nov 25 2018 CentOS_BuildTag
drwxr-xr-x 3 0 0 2048 Nov 25 2018 EFI
-rw-rw-r-- 1 0 0 227 Aug 30 2017 EULA
-rw-rw-r-- 1 0 0 18009 Dec 09 2015 GPL
drwxr-xr-x 2 0 0 2048 Nov 25 2018 LiveOS
drwxrwxr-x 2 0 0 663552 Nov 25 2018 Packages
-rw-rw-r-- 1 0 0 1690 Dec 09 2015 RPM-GPG-KEY-CentOS-7
-rw-rw-r-- 1 0 0 1690 Dec 09 2015 RPM-GPG-KEY-CentOS-Testing-7
-r--r--r-- 1 0 0 2883 Nov 25 2018 TRANS.TBL
drwxr-xr-x 3 0 0 2048 Nov 25 2018 images
drwxr-xr-x 2 0 0 2048 Nov 25 2018 isolinux
drwxrwxr-x 2 0 0 4096 Nov 25 2018 repodata
lftp 10.7.189.122:/centos7.6>

制作本地yum仓库:

本地yum仓库指:
从互联网下载*.rpm软件包到本地,需要使用安装,并且自动解决依赖关系。

1. 下载软件
模拟下载网络上的软件包

mkdir /software

cd /software

2.拷贝镜像文件中的软件包

cp /rpms/Packages/* /software

3.生成yum元数据文件

createrepo /software

4. 编写yum源配置文件

[root@test01 ~]# cat /etc/yum.repos.d/ftp.repo
[Centos7.2]
name=Centos7.2
baseurl=file:///software
enabled=1
gpgcheck=0
[root@test01 ~]#

为了解决互联网下载下来的单个rpm软件直接安装麻烦的问题

源码软件安装

步骤:

(1)下载源码软件包 ----上传服务器
保证yum源可用
(2)解压缩 *.tar.gz, *.tar.bz2
(3)配置软件的安装参数
(4) 编译,编译成计算机可执行的二进制程序
(5)安装

前提:gcc编译环境
示例:nginx

1.安装编译环境
yum -y install gcc gcc-c++

2.安装pcre软件包(使nginx支持http rewrite模块)
yum install -y pcre pcre-devel gd-deveyu

3、安装openssl-devel(使nginx支持ssl)

yum install -y openssl openssl-devel

4、安装zlib

yum install -y zlib zlib-devel

5、创建用户nginx

useradd nginx

6.安装nginx

[root@localhost ~]# wget http://nginx.org/download/nginx-1.22.0.tar.gz

7.解压nginx
[root@localhost ~]# tar xzf nginx-1.22.0.tar.gz.1 -C /usr/local/

[root@wyy nginx-1.22.0]#cd /usr/local/nginx-1.22.0
[root@nginx-1 nginx-1.22.0]# ./configure --prefix=/usr/local/nginx --group=nginx --user=nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/tmp/nginx/client_body --http-proxy-temp-path=/tmp/nginx/proxy --http-fastcgi-temp-path=/tmp/nginx/fastcgi --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-pcre --with-http_realip_module --with-stream
[root@nginx-1 nginx-1.22.0]# make 编译
[root@nginx-1 nginx-1.22.0]# make install 编译安装

7. 启动验证

[root@wyy ~]# /usr/local/nginx/sbin/nginx
nginx: [emerg] mkdir() "/tmp/nginx/client_body" failed (2: No such file or directory)

[root@wyy ~]# mkdir -p /tmp/nginx/client_boby

关闭nginx

[root@localhost ~]# /usr/local/nginx/sbin/nginx -s stop

想要卸载直接删除nginx相关的目录即可!!

半源码安装:

1. 下载软件包

https://apache.org/

2. 上传包到服务器
[root@localhost /]# ls
apache-tomcat-7.0.82.tar.gz jdk-7u79-linux-x64.gz

3. 解压

[root@localhost ~]# tar xf apache-tomcat-7.0.82.tar.gz -C /usr/local/
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# tar xf jdk-7u79-linux-x64.gz -C /usr/local/

重新改名:

[root@localhost ~]# mv /usr/local/apache-tomcat-7.0.82/ /usr/local/tomcat
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# mv /usr/local/jdk1.7.0_79/ /usr/local/java

4. 配置环境变量
[root@localhost /]# vim /etc/profile
JAVA_HOME=/usr/local/java
PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME PATH
CATALINA_HOME=/usr/local/tomcat
export CATALINA_HOME PATH

[root@localhost /]# source /etc/profile --- 生效配置文件内容

5. 验证启动服务

[root@localhost ~]# java -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

[root@localhost /]# /usr/local/tomcat/bin/startup.sh
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Using CATALINA_OPTS:
Tomcat started.

6. 验证

[root@localhost ~]# ss -antp | grep java
LISTEN 0 100 :::8009 ::😗 users:(("java",pid=8417,fd=43))
LISTEN 0 100 :::8080 ::😗 users:(("java",pid=8417,fd=42))
LISTEN 0 1 ::ffff:127.0.0.1:8005 ::😗 users:(("java",pid=8417,fd=47))

posted on 2024-08-01 20:07  海石三  阅读(99)  评论(0)    收藏  举报