学习目标
- 能够针对rpm软件包进行管理
- 能够对yum源软件进行管理
- 能够对源码包进行管理
一、RPM包管理
RPM全名是[RedHat Package Manager,是由Red Hat公司开发出来,由于非常好用,目前被很多linux发行版使用。
特点:
- 由于已经编译打包完毕,所以软件传输与安装很方便
- 查询、升级方便
1. RPM软件包常用命令
| 命令 | 作用 |
|---|---|
| rpm -ivh filename.rpm | 安装软件 |
| rpm -Uvh filename.rpm | 升级软件 |
| rpm -e filename.rpm | 卸载软件 |
| rpm -qpi filename.rpm | 查询软件的描述信息 |
| rpm -qa | 查询系统中所有的rpm软件 |
2. 案例
# 查看系统中是否已经安装了firefox[root@itcast ~]# rpm -qa | grep firefoxfirefox-24.5.0-1.el7.centos.x86_64# 如果安装先进行卸载[root@itcast ~]# rpm -e firefox# 进入系统镜像中的Packages目录[root@itcast Packages]# rpm -ivh firefox-24.5.0-1.el7.centos.x86_64.rpm准备中... ################################# [100%]正在升级/安装...1:firefox-24.5.0-1.el7.centos ################################# [100%]
RPM虽然能够使软件安装变得方便,但是在安装软件的时候依赖关系仍然需要自己解决,有些大型软件需要十多个依赖包,安装会变得复杂。这时候有进一步简化RPM管理软件的方式yum安装。
二、yum软件管理
yum软件管理是为了进一步简化RPM管理软件难度而设计的,yum能够根据用户的需求分析出所需软件包及相关依赖关系,自动从服务器下载软件包并安装到系统。
yum软件仓库:yum在下载软件时存放软件包的远程服务器
1. yum常用命令
| 命令 | 作用 |
|---|---|
| yum remove 软件包 | 移除软件包 |
| yum [-y] install 软件包名称 | 安装软件包(加y在安装时候不用输入y确认) |
| yum update 软件包名称 | 升级软件包 |
| yum list installed | 查看已安装软件包 |
2. 案例
# 查看是否安装了firefox[root@itcast Packages]# yum list installed | grep firefoxfirefox.x86_64 24.5.0-1.el7.centos @anaconda[root@itcast Packages]# yum remove firefox移除 1 软件包安装大小:87 M是否继续?[y/N]: //此处输入y[root@itcast Packages]# yum install firefox
三、源码包管理
源码包,提供了源代码需要进行配置编译才能进行操作的一种软件包形式
特点:
- 安装比较麻烦,需要配置编译等过程才能安装
- 升级、卸载不方便
- 需要手工解决依赖关系
- 用户可以修改软件代码
1. 源码包的安装步骤
./configure
创建Makefile文件,该文件记录了原始码如何编译的详细信息。编译前的准备工作。make clean
读取makefile关于clean的工作。这个步骤不一定会有,但是建议执行一下,因为我们不确定源码里有没有包含上次编译过的目标文件。make
make会根据makefile中的预设工作进行编译行为。编译就是进行gcc将源码便以为可执行文件make install
将编译好的的数据安装到预定的目录中,完成安装。
2. 案例
安装ntp时间服务器
[root@itcast ~]# tar -zxvf ntp-4.2.8p13.tar.gz[root@itcast ~]# cd ntp-4.2.8p13/[root@itcast ntp-4.2.8p13]# ./configure --prefix=/usr/local/ntp //--prefix指出安装目录[root@itcast ntp-4.2.8p13]# make[root@itcast ntp-4.2.8p13]# meke install
注意:
# 在执行./configure --prefix=/usr/local/ntp,碰到以下情况,使用后面的指令安装gcc和cc[root@localhost ntp-4.2.8p13]# ./configure --prefix=/usr/local/ntpchecking for a BSD-compatible install... /usr/bin/install -cchecking whether build environment is sane... yeschecking for a thread-safe mkdir -p... /usr/bin/mkdir -pchecking for gawk... gawkchecking whether make sets $(MAKE)... yeschecking whether make supports nested variables... yeschecking whether make supports nested variables... (cached) yeschecking build system type... x86_64-unknown-linux-gnuchecking host system type... x86_64-unknown-linux-gnuchecking for style of include used by make... GNUchecking for cc... nochecking for gcc... noconfigure: error: in `/root/ntp-4.2.8p13':configure: error: no acceptable C compiler found in $PATHSee `config.log' for more details# 安装gcc 和 cc[root@localhost ntp-4.2.8p13]# yum -y install gcc cc
