yum -y install 往往比rpm安装方便多了,能够自动关联包,但是往往每一次安装好linux后,yum 并不能直接使用。需要做一些前置设置 。
首先运行:locale 看看配置是否正确
错误描述:
当在centos中使用yum命令时,输出错误:
- Failed to set locale, defaulting to C
用locale检测,出现如下提示:
- locale:Cannot set LC_CTYPE to default locale: No such file or directory
- locale:Cannot set LC_MESSAGES to default locale: No such file or directory
- locale:Cannot set LC_ALL to default locale: No such file or directory
错误分析:
查询可知locale是用来设置语言环境的,故此需要查看并正确设置locale
解决方案:
- echo "export LC_ALL=en_US.UTF-8" >> /etc/profile
执行命令后重新登录即可!
以上设置完成后,执行yum -y install gcc,还是报错,报Could not retrieve mirrorlist [url]http://mirrorlist.centos.org/?release=5&arch=i386&repo=os[/url] error was,这时需要配置一下机器的dns,
错误原因:没有配置resolv.conf
该当:修改/etc/resolv.conf 配置nameserver IP
vi /etc/resolv.conf
nameserver #定义DNS服务器的IP地址
nameserver 为你机器上网的dns
配置以下即可