一、rpm
二、yum
三、编译安装
一、rpm
1、rpm简介
2、rpm 安装命令 (rpm -ivh --nodeps --force)
3、rpm 卸载 (rpm -e)
4、rpm 查询 (rpm -q -qa -ql -qf)
1、rpm 简介:
rpm:(Redhat Package Manager),可以在Redhat和Suse系统使用
[[email protected] ~] mount /dev/cdrom /mnt // 挂载光驱
[[email protected] ~]# ll /mnt/Packages/ | less
总用量 4264938
-r--r--r--. 2 root root 1564700 10月 18 04:01 389-ds-base-1.2.11.15-46.el6.x86_64.rpm
-r--r--r--. 2 root root 433236 10月 18 03:55 389-ds-base-libs-1.2.11.15-46.el6.i686.rpm
-r--r--r--. 2 root root 428392 10月 18 04:00 389-ds-base-libs-1.2.11.15-46.el6.x86_64.rpm
-r--r--r--. 2 root root 214692 10月 18 04:02 abrt-2.0.8-26.el6.centos.x86_64.rpm
rpm包名构成:
1、包名:abrt
2、版本号:2.0.8-26
3、系统类型:el6 指的是redhat企业版6, centos 指的是在centos上使用
4、x86_64:平台类型。 i686 32位. noarch:32位和64位皆可,没有平台限制
2、rpm 安装命令
-ivh:安装。-i install,安装;-v 可视化;-h 显示安装进度条
--nodeps:在安装或升级一个包之前不进行一个依赖性的检测
--force:强制安装,即使覆盖属于其他包的文件也要安装
-Uvh:升级rpm包
*********************************************************
--force 无法替代 --nodeps
[[email protected] ~]# rpm -ivh /mnt/Packages/amanda-2.6.1p2-8.el6.x86_64.rpm
error: Failed dependencies:
amanda-client = 2.6.1p2-8.el6 is needed by amanda-2.6.1p2-8.el6.x86_64
xinetd is needed by amanda-2.6.1p2-8.el6.x86_64
[[email protected] ~]# rpm -ivh --force /mnt/Packages/amanda-2.6.1p2-8.el6.x86_64.rpm
error: Failed dependencies:
amanda-client = 2.6.1p2-8.el6 is needed by amanda-2.6.1p2-8.el6.x86_64
xinetd is needed by amanda-2.6.1p2-8.el6.x86_64
[[email protected] ~]# rpm -ivh --nodeps /mnt/Packages/amanda-2.6.1p2-8.el6.x86_64.rpm
Preparing... ########################################### [100%]
1:amanda ########################################### [100%]
[[email protected] ~]#
*********************************************************
--force 重新安装rpm包
[[email protected] ~]# rpm -qa | grep vim
vim-common-7.2.411-1.8.el6.x86_64
vim-enhanced-7.2.411-1.8.el6.x86_64
vim-minimal-7.2.411-1.8.el6.x86_64
[[email protected] Packages]# rpm -ivh vim-common-7.2.411-1.8.el6.x86_64.rpm
Preparing... ########################################### [100%]
package vim-common-2:7.2.411-1.8.el6.x86_64 is already installed
[[email protected] Packages]# rpm -Uvh vim-common-7.2.411-1.8.el6.x86_64.rpm
Preparing... ########################################### [100%]
package vim-common-2:7.2.411-1.8.el6.x86_64 is already installed
[[email protected] Packages]# rpm -Uvh --force vim-common-7.2.411-1.8.el6.x86_64.rpm
Preparing... ########################################### [100%]
1:vim-common ########################################### [100%]
*********************************************************
3、rpm卸载
rpm -e filename // filename由rpm查询功能所查询到的
[[email protected] Packages]# rpm -qa | grep vim
vim-common-7.2.411-1.8.el6.x86_64
vim-enhanced-7.2.411-1.8.el6.x86_64
vim-minimal-7.2.411-1.8.el6.x86_64
[[email protected] Packages]# rpm -e vim-enhanced-7.2.411-1.8.el6.x86_64
[[email protected] Packages]# echo $?
0
[[email protected] Packages]# rpm -ivh vim-enhanced-7.2.411-1.8.el6.x86_64.rpm
Preparing... ########################################### [100%]
1:vim-enhanced ########################################### [100%]
[[email protected] Packages]# rpm -e vim-enhanced // 可以不带版本号
[[email protected] Packages]# echo $?
0
4、rpm 查询
rpm -q vim-enhanced 查询某个包是否安装
rpm -qa | more 查询所有
rpm -qa | grep vim 当前安装过的所有rpm包
rpm -ql vim-enhanced // rpm 所安装的文件
rpm -qf `which wim` 某个文件属于哪个rpm包
[[email protected] Packages]# rpm -qf `which vim`
vim-enhanced-7.2.411-1.8.el6.x86_64
二、yum 工具
1、yum命令
yum list 列出所有可用的rpm包资源:包括安装和未安装的
yum install -y vim
yum remove -y vim
yum update -y vim
yum provides "*/vim" 查询一个命令由哪个包安装来的
yum grouplist 列出所有套件
yum groupinstall -y Desktop " X Window System" 安装桌面环境
yum groupremove -y Desktop " X Window System"
运行以下命令生成缓存
yum clean all
yum makecache
2、创建本地yum源
[[email protected] ~]# mount /dev/cdrom /mnt // 挂载centos6.6 光盘
[[email protected] ~]# vi /etc/yum.repos.d/dvd.repo // 新建 dvd.repo本地yum源文件
[DVD]
name=local dvd
baseurl=file:///mnt
enabled=1
gpgcheck=0
[[email protected] ~]# yum list | grep DVD | tail -1 // 验证
zlib-static.x86_64 1.2.3-29.el6 DVD
3、yum 其它用法
a、 安装其它yum源
yum install -y epel-release
rpm -ivh http://www.lishiming.net/data/attachment/forum/epel-release-6-8_32.noarch.rpm
其他地址:http://www.aminglinux.com/bbs/thread-6721-1-1.html
b、yum只下载不安装
[[email protected] yum.repos.d]# yum install -y yum-plugin-downloadonly.noarch // 首先安装插件
[[email protected] yum.repos.d]# yum reinstall vim --downloadonly --downloaddir=/usr/local/src -y 将vim-enhanced 下载到/usr/local/src 目录下
三、源码包安装
[[email protected] ~]# wget http://syslab.comsenz.com/downloads/linux/httpd-2.2.16.tar.gz [[email protected] ~]# tar zxvf httpd-2.2.16.tar.gz [[email protected] ~]# cd httpd-2.2.16
[[email protected] httpd-2.2.16]# ./configure --prefix=/usr/local/apache2
[[email protected] httpd-2.2.16]# make && make install
[[email protected] httpd-2.2.16]# echo $?
0
扩展:
1. 使yum保留安装过的包 http://www.360doc.com/content/11/0218/15/4171006_94080041.shtml
2. 使用网易yum源 http://www.aminglinux.com/bbs/thread-7475-1-1.html
3. 搭建局域网yum源 http://www.aminglinux.com/bbs/thread-7627-1-1.html
4. yum源优先级 http://www.aminglinux.com/bbs/thread-7168-1-1.html
阿铭论坛:http://www.aminglinux.com/bbs/thread-7696-1-1.html