(1)源码包(脚本安装包)
(2)二进制包(rpm包,系统默认包)
(1)开源,如果有足够的能力,可以修改源代码
(2)可以自由的选择所需的功能
(3)软件是编译安装,所以更加适合自己的系统,更加稳定也效率更高
(4)卸载方便
(1)安装过程步骤较多,尤其安装较大的软件集合时,容易出现拼写错误
(2)编译过程时间较长,安装比二进制安装时间长
(3)因为是编译安装,安装过程中一旦报错新手很难解决
(1)包管理系统简单,值通过几个命令就可以实现包的安装、升级、查询和卸载
(2)安装速度比源码包安装快的多
(1)经过编译,不再可以看到源代码
(2)功能选择不如源码包灵活
(3)依赖性
(1)模块依赖查询网站:www.rpmfind.net
(1)rpm包安装命令:
rpm -ivh xxx.rpm
(1)rpm包升级命令
rpm -Uvh xxx.rpm
(1)rpm包卸载命令
rpm -e xxx --nodeps
(1)查询包是否安装
rpm -q xxx
rpm -qa |grep xxx
(2)查看包的相信信息
rpm -qi xxx
(3)查看安装位置文件列表
rpm -ql mailx
(4)查询未安装包的详细信息
rpm -qpi xxx.rpm
(5)查询系统文件所属的包
rpm -qf 系统文件名
(6)查询软件包的依赖性
rpm -qR xxx
(7)查询未安装包的依赖性
rpm -qRp xxx.rpm
(1)rpm包的校验
rpm -V xxx
若有修改,则会出现修改标志和文件类型(如下)以及对应的文件路径
文件标志
(1)rpm包中文件提取的主要应用时在当不小心将系统中某个包中的某个文件不小心删除了或者毁坏了,此时只需要查出此文件所属的rpm包,然后从此rpm包中提取出此文件,重新复制过来即可
(2)提取包文件的命令
rpm2cpio 包全名| cpio -idv .文件绝对路径
如不小心将ls命令删除了,如下及时将包中的 /bin/ls 文件提取到当前目录下
(1)首先检查一下网络连通性,如下ping www.baidu.com 可以ping通,表示当前虚拟机可以连接外网
(2)默认yum源,查看配置文件:vi /etc/yum.repos.d/CentOS-Base.repo
安装完centOS默认的配置:
(3)默认的yum源也是可以使用的,不过服务器都在国外,这里可以先把默认的都备份起来,我们从头开始配置国内的yum源
下载国内阿里云yum源配置
wget http://mirrors.aliyun.com/repo/Centos-7.repo
下载下来的国内阿里云的yum源配置文件如下:
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
(1)查看可用的rpm包
yum list
(2)搜索软件包
yum search xxx
(3)安装软件包
yum -y install xxx
(4)升级软件包(注意,这里必须指定软件包,如果不加软件包,会升级所有软件包,系统会崩溃)
yum -y update xxx
(5)卸载软件包(尽量不要使用yum remove卸载软件,很容易系统崩溃,要么就不卸载,如果要卸载,请使用rpm -e 去卸载)
yum -y remove xxx
(6)查看软件包组
yum grouplist
如下,组名显示中文,如果想查看英文组名,可以在虚拟机上看,这里是通过ssh链接查看的
(7)安装软件包组,如果组名有空格的需要使用引号括起来
yum groupinstall xxx
(8)卸载软件包组
yum groupremove xxx
(2)编辑 CentOS-Media.repo 文件,写入如下内容即可
# CentOS-Media.repo
#
# This repo can be used with mounted DVD media, verify the mount point for
# CentOS-7. You can use this repo and yum to install items directly off the
# DVD ISO that we release.
#
# To use this repo, put in your DVD and use it with the other repos too:
# yum --enablerepo=c7-media [command]
#
# or for ONLY the media repo, do this:
#
# yum --disablerepo=\* --enablerepo=c7-media [command]
[c7-media]
name=CentOS-$releasever - Media
baseurl=file:///mnt/cdrom
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
(3)RPM包默认安装后,启动文件存在如下目录中
/etc/rc.d/init.d/,因此可以使用如下两种方式启动一个服务
/etc/rc.d/init.d/xxx
或
systemctl start xxx
(4)源码安装的包,启动只能进入到软件包的安装位置去手动启动
(以安装httpd为例)
(1)安装gcc编译器
yum -y install gcc
(2)下载源码包
wget https://mirrors.gigenet.com/apache//httpd/httpd-2.4.48.tar.gz
(3)解压源码,然后将源码拷贝到 /usr/local/src/目录下,安装位置安装到:/usr/local/软件名称 下
tar -zxvf httpd-2.4.48.tar.gz
mv httpd-2.4.48 /usr/local/src/
(4)进入 /usr/local/src/xxx/ 目录下
cd /usr/local/src/httpd-2.4.48/
./configure --prefix=/usr/local/apache2
make
make install
(1)如果是本地运行,只给本地使用,选择rpm包
(2)如果是对外提供服务的,要求有大并发等的,选择源码安装,因为源码安装是根据本机编译的,比rpm包有更高的执行效率