卸载自带的 yum
1 | rpm -aq | grep yum | xargs rpm -e --nodeps |
下载及安装
下载
1 | wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm |
安装
1 | rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm |
注意最后两个安装包一定要一块安装,否则会因为相互依赖而安装失败!
添加阿里yum源
1) 备份
1 | mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup |
2) 下载新的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
3) 生成缓存
1 | yum makecache |
添加epel源
方式一
1 | yum list | grep 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 | wget -i http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm |
查看添加的yum源
1 | yum repolist enabled |
清除原有缓存
1 | yum clean all |
重建缓存,以提高搜索安装软件的速度
1 | yum makecache |
更新yum源
1 | yum -y update |
其它命令
卸载
1 | yum -y remove httpd |
列出所有已安装的软件包
1 | yum list installed |
列出所有可安装的软件包
1 | yum list nginx |
列出所有可更新的软件包
1 | yum list updates |
使用YUM获取软件包信息
1 | yum info nginx |
列出所有已安装的软件包信息
1 | yum info installed |
列出所有可更新的软件包信息
1 | yum info updates |
常用位置
下面软件的安装位置一般为yum
安装后的位置
- 服务位置:
/etc/init.d/
- apache:
/etc/httpd/conf/
- nginx:
/etc/nginx/
- tomcat7:
/usr/share/tomcat7
- mysql:
/etc/my.cnf