rpm== redhat package manager
zlib-devel-1.2.3-29.el6.i686.rpm 包名-主版本号.次版本号.修订版本号-红帽企业版本6-32位系统.rpm包
如果不写明 i686 或ix86 就代表兼容这个32位和64位的系统
[root@daixuan Packages]# ls |grep 'centos' 查看包名中包含“centos”
abrt-2.0.8-34.el6.centos.i686.rpm
abrt-addon-ccpp-2.0.8-34.el6.centos.i686.rpm
abrt-addon-kerneloops-2.0.8-34.el6.centos.i686.rpm
如果安装过程中出现安装的两个包相互依赖,只能同时安装
[root@daixuan Packages]# rpm -ivh yp-tools-2.9-12.el6.i686.rpm ypbind-1.20.4-31.el6.i686.rpm
Preparing... ########################################### [100%]
1:ypbind ########################################### [ 50%]
2:yp-tools ########################################### [100%]
[root@daixuan Packages]# rpm -e ypbind yp-tools 同时卸载包ypbind和包yp-tools,使用-e
[root@daixuan Packages]# rpm --nodeps yp-tools-2.9-12.el6.i686.rpm 不安装依赖,只安装当前包
[root@daixuan Packages]# rpm --force yp-tools-2.9-12.el6.i686.rpm 强制安装,即使安装过
[root@daixuan Packages]# rpm -Uvh yp-tools-2.9-12.el6.i686.rpm 升级rpm包,-U
[root@daixuan ~]# rpm -qa 列出所有安装过的包
[root@daixuan ~]# rpm -qi vim-enhanced 列出指定安装包名的详细信息
Name : vim-enhanced Relocations: (not relocatable)
Version : 7.4.629 Vendor: CentOS
Release : 5.el6 Build Date: 2015年07月24日 星期五 10时19分54秒
Install Date: 2015年10月29日 星期四 13时56分35秒 Build Host: c6b8.bsys.dev.centos.org
[root@daixuan ~]# rpm -qf /usr/bin/vim rpm -qf 文件名绝对路径,可以查看该文件由哪个包安装的
vim-enhanced-7.4.629-5.el6.i686
[root@daixuan ~]# which vim 查看vim的安装路径
/usr/bin/vim
vim-enhanced-7.4.629-5.el6.i686
[root@daixuan ~]# rpm -qf `which vim` <==> 查看vim由哪些包安装的,vim路径由which找到
vim-enhanced-7.4.629-5.el6.i686[root@daixuan Packages]# rpm -ql vim-enhanced rpm -ql 包名,可以查看该包安装哪些文件
/etc/profile.d/vim.csh
/etc/profile.d/vim.sh
/usr/bin/rvim
/usr/bin/vim
/usr/bin/vimdiff
/usr/bin/vimtutor
yum优势
1、自动解决安装包之间的依赖关系
2、在库中搜索到所有适合本平台安装包,通过网路下载
[root@daixuan Packages]# yum list 列出网络yum安装资源,比光盘的安装文件多很多[root@daixuan ~]# vim /etc/yum.repos.d/CentOS-Base.repo 可以查看安装源网址,并且可以修改
[base] name=CentOS-$releasever - Base mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
[root@daixuan ~]# yum search vim 使用search搜索相关安装包
[root@daixuan ~]# yum list | grep vim 查看vim相关的安装包,@代表已经安装的包,没有@前缀,说明包没有安装,可以安装
vim-common.i686 2:7.4.629-5.el6 @base
vim-enhanced.i686 2:7.4.629-5.el6 @base
vim-filesystem.i686 2:7.4.629-5.el6 @base
vim-minimal.i686 2:7.4.629-5.el6 @anaconda-CentOS-201508042139.i386/6.7
vim-X11.i686 2:7.4.629-5.el6 base
[root@daixuan ~]# yum install -y vim-X11 安装vim-X11.i686包
[root@daixuan ~]# yum update vim-enhanced 升级安装包vim-enhanced
[root@daixuan ~]# yum upgrade vim-enhanced 升级安装包vim-enhanced
[root@daixuan ~]# yum remove vim-enhanced yum 卸载安装包 不建议使用-y选项,否则将相关依赖包卸载,其他命令将不能使用。
Remove 1 Package(s)
Installed size: 2.1 M
确定吗?[y/N]:y
[root@daixuan ~]# vim 1234.txt
-bash: /usr/bin/vim: 没有那个文件或目录 已经卸载成功
[root@daixuan ~]# LANG=zh_CN.UTF-8 系统改为中文
[root@daixuan ~]# LANG=en 系统改为英文
[root@daixuan ~]# yum grouplist 列出已安装和可安装的资源
vailable Language Groups:
Afrikaans Support [af]
Print Server
[root@daixuan ~]# yum groupinstall "Print Server" 安装套件
[root@daixuan ~]# yum groupremove "Print Server" 卸载套件
使用本地光盘制作yum源yum源的读取首先检查CentOS-Base.repo这个文件,如果没有,就去读取CentOS-Media.repo这个文件的配置
[root@daixuan mnt]# mount /dev/cdrom /mnt
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@daixuan mnt]# cd /etc/yum.repos.d/
[root@daixuan yum.repos.d]# ls
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Media.repo CentOS-Vault.repo
[root@daixuan yum.repos.d]# cd ..
[root@daixuan etc]# cp -r yum.repos.d/ yum.repos.d.bak 备份网络yum源配置文件
[root@daixuan etc]# cd yum.repos.d
[root@daixuan yum.repos.d]# ls
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Media.repo CentOS-Vault.repo
[root@daixuan yum.repos.d]# rm -rf CentOS-Base.repo
[root@daixuan yum.repos.d]# yum list
[root@daixuan yum.repos.d]# ls
CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Media.repo CentOS-Vault.repo
[root@daixuan yum.repos.d]# vim CentOS-Media.repo
[local_cdrom]
name=cd cd是yum源的名字标识,可以去掉
baseurl=file:///mnt/
gpgcheck=0 是否检测,=0不检测
enabled=1 让其生效
[root@daixuan yum.repos.d]# yum list
zlib-static.i686 1.2.3-29.el6 local_cdrom
zsh.i686 4.3.11-4.el6.centos local_cdrom
zsh-html.i686 4.3.11-4.el6.centos local_cdrom[root@daixuan yum.repos.d]# LANG=en
[root@daixuan yum.repos.d]# yum groupinstall -y "Russian Support" 则此时从本地cd盘中找到rpm源文件安装并安装Russian Support套件
yum如何下载rpm包到本地
注:
需要先安装yum-plugin-downloadonly包才可以正常下载rpm包
下载的过程,其实就是yum把rpm下载下来不安装而已,命令也是使用yum install
想要下载的rpm包如果有依赖的包,那么yum会把所有依赖包也下载下来
[root@daixuan yum.repos.d]# pwd
/etc/yum.repos.d
[root@daixuan yum.repos.d]# cp ../yum.repos.d.bak/CentOS-Base.repo . 将备份的CentOS-Base.repo(yum安装网络路径)拷贝到yum/etc/yum.repos.d路径下
[root@daixuan yum.repos.d]# ls
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo CentOS-fasttrack.repo
[root@daixuan yum.repos.d]# yum list | grep download 查看download相关包名
Failed to set locale, defaulting to C
yum-plugin-downloadonly.noarch 1.1.30-30.el6 base
[root@daixuan yum.repos.d]# yum -y install yum-plugin-downloadonly 安装yum的下载插件
[root@daixuan yum.repos.d]# yum install vte --downloadonly --downloaddir=/tmp/ 本机如果没有安装过该包,就会去下载
[root@daixuan yum.repos.d]# yum reinstall vte --downloadonly --downloaddir=/tmp/ 本机已经安装过,需要再次下载使用reinstall,用install不下载
源码安装
类似于rpm和yum,首先需要到官网上下载源文件,官网: apache.org
download
http://mirror.bit.edu.cn/apache/
http/
httpd-2.2.31.tar.bz2 右键复制下载链接
[root@daixuan yum.repos.d]# yum install -y wget wget是获取源码包的命令,需要提前安装
[root@daixuan yum.repos.d]# wget http://mirror.bit.edu.cn/apache/httpd/httpd-2.2.31.tar.bz2
[root@daixuan yum.repos.d]# mv httpd-2.2.31.tar.bz2 /usr/local/src 习惯约定下载路径
[root@daixuan src]# ls
httpd-2.2.31.tar.bz2
[root@daixuan src]# tar -jxvf httpd-2.2.31.tar.bz2
[root@daixuan src]# ls
httpd-2.2.31 httpd-2.2.31.tar.bz2
[root@daixuan src]# cd httpd-2.2.31
[root@daixuan httpd-2.2.31]# ls
[root@daixuan httpd-2.2.31]# vim INSTALL 查看如何安装,通常是三个步骤
Quick Start - Unix
------------------
For complete installation documentation, see [ht]docs/manual/install.html or
http://httpd.apache.org/docs/2.2/install.html
$ ./configure --prefix=PREFIX
$ make
$ make install
$ PREFIX/bin/apachectl start[root@daixuan httpd-2.2.31]# vim README 查看介绍信息
Apache HTTP Server
What is it?
-----------
The Apache HTTP Server is a powerful and flexible HTTP/1.1 compliant
web server. Originally designed as a replacement for the NCSA HTTP
Server, it has grown to be the most popular web server on the
Internet. As a project of the Apache Software Foundation, the
developers aim to collaboratively develop and maintain a robust,
commercial-grade, standards-based server with freely available
source code.
源码安装三个步骤
步骤一:
[root@daixuan httpd-2.2.31]# ./configure --help
[root@daixuan httpd-2.2.31]# ./configure --prefix=/usr/local/apache2 --prefix指定安装路径,2代表apache2版本,习惯约定安装路径/usr/local/下
config.status: creating build/pkg/pkginfo creating 一般代表成功,可用 echo $? 确认
config.status: creating build/config_vars.sh
config.status: creating include/ap_config_auto.h
[root@daixuan httpd-2.2.31]# echo $? 看这一步返回码是不是0,是0,则安装正常
0
步骤二:make 编译的过程,把源码翻译成计算机语言,时间有点长
[root@daixuan httpd-2.2.31]# make
[root@daixuan httpd-2.2.31]# echo $? 看这一步返回码是不是0,是0,表示安装正常
0
步骤三:make install就是把机器编译完成的二进制可执行文件拷贝到指定的目录下
[root@daixuan httpd-2.2.31]# make install
[root@daixuan httpd-2.2.31]# ls /usr/local/apache2/ 该目录下已经有了可执行文件
bin cgi-bin error icons lib man modules
build conf htdocs include logs manual
注:在编译安装源码包时,如果遇到错误类似于"checking for cc... no",需要如何做?
yum install gcc