使用yum安装软件,会自动把需要的rpm包安装上,这一点要比rpm命令一个一个包安装要方便得多,并且也不必考虑rpm包得安装顺序。
不过yum默认会指向红帽网络来搜索软件需要的安装包,那我们能不能让linux从本地光驱的安装光盘里搜索安装包呢?答案是肯定的~
下面我们就来实现这个功能:
1.将光盘挂载到/mnt/cdrom目录下
root权限执行mount -t iso9660 /dev/cdrom /mnt/cdrom/
2.修改yum源的路径:
vi /etc/yum.repos.d/rhel-debuginfo.repo
添加一下内容:
[Cluster]
name=Red Hat Enterprise Linux $releasever - $basearch - Cluster
baseurl=file:///mnt/cdrom/Cluster #修改为mount point的实际路径
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[ClusterStorage]
name=Red Hat Enterprise Linux $releasever - $basearch - ClusterStorage
baseurl=file:///mnt/cdrom/ClusterStorage
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[Server]
name=Red Hat Enterprise Linux $releasever - $basearch - Server
baseurl=file:///mnt/cdrom/Server
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[VT]
name=Red Hat Enterprise Linux $releasever - $basearch - VT
baseurl=file:///mnt/cdrom/VT
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
3.vim /usr/lib/python2.4/site-packages/yum/yumRepo.py
修改第799行
将remote = url + '/' + relative
修改为:remote = "/mnt/cdrom/Server" + '/' + relative
4.执行yum clean all 清楚数据缓存
5.执行yum install php 测试yum的源是否修改成功:
结果显示已成功安装php所需的包。
转载于:https://blog.51cto.com/bxuan/668322