本地和网络yum源的配置
rpm -ivh xxx
手动添加依赖,yum不执行安装,自动处理依赖管理
yum优点
rpm安装(下载软件,单独安装,需要解决依赖关系)
源码安装configure make make install
yum基于rpm,相当于rpm升级版,自动解决依赖关系
1.使用光盘作为yum源仓库
1)在vmware中装载centos7光盘镜像
将原有的yum备份或改名
[root@tdr ~]# cd /etc/yum.repos.d/
[root@tdr yum.repos.d]# ls
haha.repo
[root@tdr yum.repos.d]# mv haha.repo haha.repo.q
[root@tdr yum.repos.d]# ls
haha.repo.q
[root@tdr yum.repos.d]# yum repolist
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
repolist: 0 //yum已全部被清除
2)把光盘挂载到指定⽬录下
[root@tdr ~]# rm -rf /mnt/*
[root@tdr ~]# mount -o ro /dev/sr0 /mnt //-o表示挂载方式,ro表示readonly
将光盘数据挂载到/mnt目录中,就可以在该目录中读取光盘的数据
[root@tdr ~]# df -h
3)将挂载添加到开机启动⽂件中
[root@tdr ~]# vim /etc/rc.local //开机自动执行挂载
mount -o ro /dev/sr0 /mnt
或[root@tdr ~]# vim /etc/fstab //也是开机自动挂载
/dev/cdrom /mnt iso9660 defaults 0 0
4)编写本地repo⽂件
[root@tdr ~]# vim /etc/yum.repos.d/local.repo
[local]
name=local
baseurl=file:///mnt
gpgcheck=0
enable=1
5)清理缓存,查看源列表
[root@tdr ~]# yum clean all //清除缓存
[root@tdr ~]# yum makecache //生成缓存
6)测试yum
[root@tdr ~]# yum -y remove httpd
[root@tdr ~]# yum -y install httpd
2.配置网络源
1)阿里云
[root@tdr ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
[root@tdr ~]# yum clean all
[root@tdr ~]# yum makecache
[root@tdr ~]# yum list | grep python3
2)腾讯云
[root@localhost yum.repos.d]# rm -rf /etc/yum.repos.d/CentOS-Base.repo
[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo
http://mirrors.cloud.tencent.com/repo/centos7_base.repo
[root@localhost ~]# yum clean all
[root@localhost ~]# yum makecache
3)epel源配置
对官⽅和官⽹源的扩展,有些软件找不到
[root@localhost ~]# yum -y install epel-release
安装⼩⽕⻋
[root@localhost ~]# yum -y install sl
移除epel源,如果不⾏就全清空
[root@localhost ~]# rm -rf /etc/yum.repos.d/epel.repo
[root@localhost ~]# yum clean all
[root@localhost ~]# yum makecache
4)安装特定软件源配置nginx
https://nginx.org/
找到repo文件内容
安装稳定版本
[root@localhost ~]# vim /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
[root@localhost ~]# yum clean all
[root@localhost ~]# yum makecache
[root@localhost ~]# yum -y install nginx
[root@localhost ~]# nginx //启动服务
[root@localhost ~]# whereis nginx //查看指令
浏览器访问本机IP
[root@localhost ~]# nginx -s stop //停⽤nginx
5)自建yum源仓库
[root@localhost ~]# vim /etc/yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever //定义软件包缓存路径
keepcache=1 //修改为1,开启缓存
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?
project_id=23&ref=http://bugs.centos.org/bug_report_page.php?
category=yum
distroverpkg=centos-release
卸载,然后安装nginx 查看缓存⽂件
[root@localhost ~]# yum -y remove nginx.x86_64 //卸载
[root@localhost ~]# yum install nginx -y //安装
[root@localhost ~]# find /var/cache/ -name "*nginx*" -type f //查找安装包
/var/cache/yum/x86_64/7/os/packages/tree-1.6.0-10.el7.x86_64.rpm
只下载不安装
[root@localhost ~]# yum install --downloadonly --downloaddir=./soft samba
[root@localhost ~]# ls soft/ //安装包的位置
(1)安装createrepo制作仓库的软件
[root@localhost ~]# yum -y install createrepo
(2)把soft⽂件夹做成⼀个本地的⾃建仓库
[root@localhost ~]# createrepo soft/
[root@localhost ~]# cd soft/
[root@localhost soft]# ls
(3)在/etc/yum.repos.d/下创建soft.repo
[root@localhost soft]# rm -rf /etc/yum.repos.d/*.repo //删除其他仓库⽂件
[root@localhost soft]# vim /etc/yum.repos.d/soft.repo //配置仓库文件
[soft]
name=soft_local
gpgcheck=0
baseurl=file:///root/soft
enable=1
[root@localhost soft]# yum clean all
[root@localhost soft]# yum makecache
[root@localhost soft]# yum -y install samba //再次安装samba,不用再次下载