卸载自带的 yum
1
| rpm -aq | grep yum | xargs rpm -e --nodeps
|
下载及安装
下载
1 2 3 4
| wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-73.el6.centos.noarch.rpm wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-37.el6.noarch.rpm
|
安装
1 2 3
| rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm rpm -ih yum-metadata-parser-1.1.2-16.el6.x86_64.rpm rpm -ivh yum-3.2.29-73.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-37.el6.noarch.rpm
|
注意最后两个安装包一定要一块安装,否则会因为相互依赖而安装失败!
添加阿里yum源
- 备份
1
| mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
|
- 下载新的CentOS-Base.repo 到/etc/yum.repos.d/
CentOS 7
1
| wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
|
CentOS 6
1
| wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
|
CentOS 5
1
| wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
|
- 生成缓存
添加epel源
方式一
1 2
| yum list | grep epel-release yum install -y epel-release
|
方式二
使用阿里epel源
1
| wget -O /etc/yum.repos.d/epel-7.repo http://mirrors.aliyun.com/repo/epel-7.repo
|
添加Nginx源
1
| rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
|
添加Mysql源
1 2
| wget -i http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm yum -y install mysql57-community-release-el7-7.noarch.rpm
|
查看添加的yum源
清除原有缓存
重建缓存,以提高搜索安装软件的速度
更新yum源
其它命令
卸载
列出所有已安装的软件包
列出所有可安装的软件包
列出所有可更新的软件包
使用YUM获取软件包信息
列出所有已安装的软件包信息
列出所有可更新的软件包信息
常用位置
下面软件的安装位置一般为yum安装后的位置
- 服务位置:
/etc/init.d/
- apache:
/etc/httpd/conf/
- nginx:
/etc/nginx/
- tomcat7:
/usr/share/tomcat7
- mysql:
/etc/my.cnf