新安装好的Centos是没有安装gcc的,若是在联网的情况下安装gcc,运行(需要配置好dns服务器)
下面要介绍的是在离线的情况下安装gcc,前提是需要有安装盘
因为安装盘里有gcc,我们把安装盘当作一个本地yum源
- #设置光驱挂载点
- mkdir -p /Application/cdrom
- #挂载光驱
-
mount /dev/cdrom /Application/cdrom
- #备份原yum源
-
cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
- #把光驱设为yum源
-
echo "[base]" > /etc/yum.repos.d/CentOS-Base.repo
-
echo "name=CentOS-$releasever - Base" >> /etc/yum.repos.d/CentOS-Base.repo
-
echo "baseurl=file:///Application/cdrom/" >> /etc/yum.repos.d/CentOS-Base.repo
-
echo "gpgcheck=0" >> /etc/yum.repos.d/CentOS-Base.repo
- #安装gcc
-
yum install gcc -y
- #恢复原yum源
-
cp –f /etc/yum.repos.d/CentOS-Base.repo.bak /etc/yum.repos.d/CentOS-Base.repo
end
阅读(9358) | 评论(0) | 转发(1) |