装了Linux虚拟机rhel-server-6.4 版本后,在网上看到利用 yum -y install gcc安装gcc的教程,遇到的各种问题,因为是小白,一步一步详解如下:
1.首先切换root账号:
输入su后输入密码, 切换到root $ -> #
2. 按照网上教程输入, yum -y install gcc ,并没有成功,返回Error。网上搜了一下需要先删除掉redhat自带的yum包。
[[email protected] ~]# rpm -qa|grep yum|xargs rpm -e --nodeps(不检查依赖,直接删除rpm包)
再用
[[email protected] ~]# rpm -qa |grep yum
[[email protected] ~]#
3.下载yum包
#wget url/yum-3.2.27-14.el6.centos.noarch.rpm
#wget url/yum-metadata-parser-1.1.2-14.1.el6.x86_64.rpm
#wget url/yum-plugin-fastestmirror-1.1.26-11.el6.noarch.rpm
#wget url/python-iniparse-0.3.1-2.1.el6.noarch.rpm
注:网上的url绝大多数都是不准的, 自己根据系统位数将url替换下面的路径:
32位: http://mirrors.163.com/centos/6/os/i386/Packages/
64位:http://tel.mirrors.163.com/centos/6/os/x86_64/Packages/
可以打开上面的路径自己查找。
4. 安装
注意:单个的安装包可能会依赖其它包(例如yum和yum-fastestmirror会相互依赖),所以我们可以把所有这些包放在一起,用一行命令将它们同时安装即可:
#rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm
# rpm -ivh yum-metadata-parser-1.1.2-14.el6.i686.rpm
yum-3.2.27-14.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.26-11.el6.noarch.rpm
5. yum配置
# cd /etc/yum.repos.d/
# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
# vi CentOS6-Base-163.repo
修改如下几处:
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
[base]
name=CentOS-6 - Base - 163.com
baseurl=http://mirrors.163.com/centos/6/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#released updates
[updates]
name=CentOS-6 - Updates - 163.com
baseurl=http://mirrors.163.com/centos/6/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#additional packages that may be useful
[extras]
name=CentOS-6 - Extras - 163.com
baseurl=http://mirrors.163.com/centos/6/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-6 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/6/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#contrib - packages by Centos Users
[contrib]
name=CentOS-6 - Contrib - 163.com
baseurl=http://mirrors.163.com/centos/6/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
保存退出 (按esc之后, wq )
6.清除原有缓存
# yum clean all
PS: 本人在此处还是会有报错, 进入etc/yum.repos.d/后发现还有多余的几个.repo文件,所以发狠 rm -rf
删了干净,重新来过,终于搞定!
重建缓存,以提高搜索安装软件的速度
# yum makecache
更新系统
# yum update
PS:
查看Linux是32还是64:
1.uname -a
例如我的机子输入命令后输出:
Linux zou-acertox42 2.6.38-10-generic #46-Ubuntu SMP Tue Jun 28 15:05:41 UTC 2011 i686 i686 i386 GNU/Linux
如果是64位的则可能输出:
Linux web1 2.6.9-22.ELsmp #1 SMP Mon Sep 19 18:00:54 EDT 2005 x86_64 x86_64 x86_64 GNU/Linux
2. #getconf LONG_BIT