一、本地yum源光盘配置
1.查看现有的yum仓库镜像
2.查看所有镜像文件
3.将yum.repos.d下的所有文件打包成压缩包
4.删除yum.repos.d下以.repo结尾的文件
5.配置yum源仓库
yum仓库的格式
编号 | 属性 |
1 | [仓库名称] 可以有多个仓库 |
2 | name=仓库描述 |
3 | baseurl=仓库的路径,支持多种格式file:///mnt |
4 | enabled=1/0 是否启用当前仓库,1启用,0不启用 |
5 | gpgcheck=0/1表示秘钥检测,0不检测,1检测 |
6.显示以配置的文件仓库列表及各个软件仓库的软件包数量
此时发现报错,而仓库数量显示为0
然后我们回到虚拟机,发现虚拟机设置中的设备状态,没有选中已连接
只需选中已连接,然后点击确定就好了
7.挂载虚拟光盘,将、/dev/cdrom挂载到mnt目录下,然后再次查看仓库数量
查看磁盘挂载情况
8.编辑永久挂载的文件
9.自动挂载
为方便后续操作,我们安装vim及net-tools
由于新建的虚拟机没有vim指令,只有vi,安装vim后我们能正常使用vim指令
安装net-tools后我们可以使用ifconfig命令,更方便我们查看虚拟机IP地址
10.测试yum
查看是否安装httpd
卸载httpd
再次查看是否安装httpd
重新安装httpd
再次查看是否安装httpd
二、网络yum源配置
1.百度搜索框搜索“阿里mirror镜像站点”
点击下载地址:
https://developer.aliyun.com/mirror/centos
2.根据官方提示配置yum源
(1)下载
![](https://i-blog.csdnimg.cn/direct/3fff93886bca4401945846687f594b12.png)
(2)生成缓存
yum makecache
(3)清空内存
yum clean all
(4)查看源
yum repolist all
![](https://i-blog.csdnimg.cn/direct/a58b6ff912424633897c75c7ed34e671.png)
3.epel源配置
(1)下载epel软件包
yum -y install epel-release
![](https://i-blog.csdnimg.cn/direct/5bfc70b198814fa2bbe3a1825393fb0e.png)
(2)查看安装情况
![](https://i-blog.csdnimg.cn/direct/addeac5a06cb4d929e512dcfe7fec9d6.png)
(3)使用ls查看yum.repos.d目录
![](https://i-blog.csdnimg.cn/direct/fb90d5bccb98450499031558bb927a95.png)
4.安装小火车
(1)安装软件包:
yum -y install sl
![](https://i-blog.csdnimg.cn/direct/093b00995b5540dfb41426ab698044c5.png)
(2)使用sl查看,可以看到小火车图案
![](https://i-blog.csdnimg.cn/direct/d164a8c8008c4a4fa1cf310197670929.png)
三、特定软件源配置--nginx
1.搜nginx的镜像
百度搜索 https://nginx.org/
![](https://i-blog.csdnimg.cn/direct/e24ce54637d04fba922e9dc91b751cf3.png)
2.搜document
![](https://i-blog.csdnimg.cn/direct/5ba85feadb1247a0b87814bd29ef6e92.png)
3.搜install
![](https://i-blog.csdnimg.cn/direct/7623a1855be8450db3521f6d36829434.png)
4.点击packages
![](https://i-blog.csdnimg.cn/direct/434c123828c24a41a60f384faf3d1ab5.png)
5.找到repo⽂件内容
![](https://i-blog.csdnimg.cn/direct/bc597acc1d1a4882b6961943883d4555.png)
6.安装稳定版本
[root@localhost ~]# vim /etc/yum.repos.d/nginx.repo
![](https://i-blog.csdnimg.cn/direct/3eedceed75b94aa4b2e64965723c99c5.png)
7.创建缓存
[root@localhost ~]# yum clean all
[root@localhost ~]# yum makecache
[root@localhost ~]# yum list|grep nginx
8.安装并且检查
[root@localhost ~]# yum install nginx -y
9.启动服务
[root@localhost ~]# nginx
10. 查看指令
[root@localhost ~]# whereis nginx
11. 访问服务器
[root@localhost ~]# curl http://localhost
12.停⽤nginx
[root@localhost ~]# nginx -s stop
13.访问测试
[root@localhost ~]# curl http://localhost
四、⾃建yum源仓库
1.缓存安装软件包
-----使得下一次还能够使用
2.如何缓存
[root@localhost ~]#vim /etc/yum.conf[main]cachedir=/var/cache/yum/$basearch/$releaserver # 定义软件包缓存路径keepcache=1 #开启缓存debuglevel=2logfile=/var/log/yum.log
3.卸载,然后安装nginx 查看缓存⽂件
(1)卸载
[root@localhost ~]# yum -y remove nginx.x86_64
(2)安装
[root@localhost ~]# yum -y install nginx
(3)查找安装包
[root@localhost ~]# find /var/cache/ -name "*tree*" -type f/var/cache/yum/x86_64/7/os/packages/tree-1.6.0-10.el7.x86_64.rpm
[root@localhost ~]# find /var/cache/ -name "*nginx*" -type f/var/cache/yum/x86_64/7/nginx-stable/packages/nginx-1.26.1-2.el7.ngx.x86_64.rpm
(4)只下载不安装
[root@localhost ~]# yum install --downloadonly --downloaddir=./soft samba
[root@localhost ~]# ls soft/
五、安装createrepo制作仓库软件
1.下载createrepo的安装包
[root@localhost ~]# yum -y install createrepo
2.把soft⽂件夹做成⼀个本地的⾃建仓库
[root@localhost ~]# createrepo soft/
[root@localhost ~]# ls
[root@localhost ~]# cd soft/
[root@localhost soft]# ls
3.在/etc/yum.repos.d/下创建 soft.repo
vim /etc/yum.repos.d/soft.repo[soft]name=soft_localgpgcheck=0baseurl=file:///root/softenable=1
4.删除其他仓库⽂件
[root@localhost soft]# rm -rf /etc/yum.repos.d/*.repo[root@localhost soft]# ls /etc/yum.repos.d/repo.tar.gz
5.配置仓库⽂件
[root@localhost soft]# vim /etc/yum.repos.d/soft.repo
6.创建缓存
[root@localhost soft]# yum clean all已加载插件:fastestmirror正在清理软件源: softCleaning up list of fastest mirrorsOther repos take up 748 M of disk space (use --verbose for details)[root@localhost soft]# yum makecache已加载插件:fastestmirror
7. 再次安装samba
[root@localhost soft]# yum -y install samba