linux中没有默认安装的gcc,折腾了一番,终于搞好,记录备忘。

[root@localhost local]# gcc
bash: gcc: command not found...

查看系统版本:

[root@localhost ~]# cat /proc/version
Linux version 3.10.0-229.el7.x86_64 (mockbuild@x86-035.build.eng.bos.redhat.com) (gcc version 4.8.3 20140911 (Red Hat 4.8.3-7) (GCC) ) #1 SMP Thu Jan 29 18:37:38 EST 2015
[root@localhost ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.1 (Maipo) 

red hat中yum需要付费

[root@localhost local]# yum install gcc
Loaded plugins: langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

主要有两种方式解决此问题:

一、通过yum安装,第一种通过替换成CentOS的yum,然后直接 yum install gcc 安装;

第二种通过本地镜像文件来装,用iso做一个yum库(无法联网时的办法)。

二、直接安装gcc,第一种通过rpm安装(依赖包挺多的,很繁琐);第二种通过gcc压缩包安装。

此处只叙述了本人成功的一种方式,其他方式可以搜一下,有很多文章进行了叙述。

1、安装yum,替换成CentOS中的yum,通过yum install gcc安装,通过此方式要确定服务器能上网

a. 备份原 yum

mv /etc/yum.repos.d/redhat.repo /etc/yum.repos.d/redhat.repo.backup

b. 删除red hat yum源

rpm -qa | grep yum | xargs rpm -e --nodeps 

c. 下载新的yum包,因为是red hat 7 安装CentOS 7 版本的yum源,版本一定要对应,可避免不少麻烦
    去http://mirrors.163.com/centos/7/os/x86_64/Packages/下载如下文件
    下载:yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
               yum-3.4.3-154.el7.centos.noarch.rpm
               yum-plugin-fastestmirror-1.1.31-42.el7.noarch.rpm
               python-iniparse-0.4-9.el7.noarch.rpm
  或者命令下载直接:

wget  http://mirrors.163.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
wget  http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget  http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-154.el7.centos.noarch.rpm
wget  http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-42.el7.noarch.rpm

d. 安装新的yum包

rpm -ivh python-iniparse-0.4-9.el7.noarch.rpm
rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
rpm -ivh yum-3.4.3-154.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-42.el7.noarch.rpm

安装后可通过命令查看:

[root@localhost ~]# rpm -qa |grep yum
yum-plugin-fastestmirror-1.1.31-42.el7.noarch
yum-3.4.3-154.el7.centos.noarch
yum-metadata-parser-1.1.4-10.el7.x86_64

如果报错缺少包,可以将包名复制到http://mirrors.163.com/centos/7/os/x86_64/Packages/ 下去找对应的包,并下载安装。

如:可能会缺少python-urlgrabber这个包,就先下载安装这个包。

e. 将CentOS的yum源更新到red hat中
下载地址:http://mirrors.163.com/.help/CentOS6-Base-163.repo
将repo文件移动到 /etc/yum.repos.d/下,并编辑 (把版本号换成7就行)

[root@localhost ~]# mv CentOS6-Base-163.repo /etc/yum.repos.d/
[root@localhost ~]# 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-7-Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever6&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
baseurl=http://ftp.sjtu.edu.cn/centos/7/os/$basearch/
gpgcheck=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#released updates[update]
name=CentOS-7-Updates
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=updates
baseurl=http://ftp.sjtu.edu.cn/centos/7/updates/$basearch/
gpgcheck=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#packages used/produced in the build but not released[extras]
name=CentOS-7-Extras
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=extras
baseurl=http://ftp.sjtu.edu.cn/centos/7/extras/$basearch/
gpgcheck=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#additional packages that extend functionality of existing packages[centosplus]
name=CentOS-7-Plus
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=centosplus
baseurl=http://ftp.sjtu.edu.cn/centos/7/centosplus/$basearch/
gpgcheck=0
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#contrib - packages by Centos Users[contrib]
name=CentOS-7-Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=contrib
baseurl=http://ftp.sjtu.edu.cn/centos/7/contrib/$basearch/
gpgcheck=0
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

如果后面有报找不到key的问题,可以下载对应的key,然后将gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

指定成本地文件gpgkey=file:///usr/local/yum/RPM-GPG-KEY-CentOS-6

f. 清理yum缓存

[root@localhost ~]# yum clean all
[root@localhost ~]# yum makecache

g. 就可以安装测试啦!

yum install gcc

Red Hat Enterprise Linux Server release 7.1 (Maipo) 安装gcc 的几种方式相关推荐

  1. Red Hat Enterprise Linux Server release 7.4 (Maipo) 安装mysql5.7.36

    1. 版本 [root@localhost mysql]# cat /etc/redhat-release Red Hat Enterprise Linux Server release 7.4 (M ...

  2. AWS EC2 云服务器 Red Hat Enterprise Linux Server release 7.4 (Maipo) vnc远程连接教程

    1.AWS亚马逊云端设置完全访问组TCP连接端口 2.使用xshell登录隧道转发5901端口 选择私有认证秘钥 点击隧道进行配置 3.下载安装redhat 7.4  gnome及配置 #yum up ...

  3. Red Hat Enterprise Linux Server release 6.3下ganglia监控系统的搭建

    ganglia 是分布式的监控系统,有两个Daemon, 分别是:客户端Ganglia Monitoring Daemon (gmond)和服务端Ganglia Meta Daemon (gmetad ...

  4. Red Hat Enterprise Linux Server release 7.0双系统安装

    2019独角兽企业重金招聘Python工程师标准>>> Red Hat Enterprise Linux Server release 7.0双系统安装 1.RedHat 公司的企业 ...

  5. 1-4-RHEL6.3-用户及组管理(Red Hat Enterprise Linux Server release 6.3)@树袋飘零

    本节介绍内容: 1.账户和组的概念 2.账户和组文件阐述与解析 3.管理账户和组(创建删除和修改) 4.案例分析-用户管理和组管理 5.暴力破解RHEL5 shadow 1.账户和组的概念 用户和组的 ...

  6. Red Hat Enterprise Linux Server release 5.6 安装 MongoDB 2.6.4

    1:下载 [jifeng@jifeng04 ~]$ wget http://downloads.mongodb.org/linux/mongodb-linux-x86_64-2.6.4.tgz --2 ...

  7. redhat Enterprise Linux Server release 7.2(Maipo) 安装redis-stat

    项目需要在rh7.2安装redis-stat,各种编译不过.通过一步步跟踪编译错误日志发现时缺少各种开发库. 需要安装的库列表如下: zlib-devel openssl-devel readline ...

  8. zzw原创_Red Hat Enterprise Linux Server release 6.5 安装mysql5.5.28版本

    1.查看系统版本 [root@ip12189 ~]#  more /etc/issue Red Hat Enterprise Linux Server release 6.5 (Santiago) K ...

  9. Red Hat Enterprise Linux 7 Release Candidate Now Publicly Available

    2014年4月23日 The Red Hat Enterprise Linux Team As mentioned during Red Hat Summit 2014 last week, we a ...

最新文章

  1. pandas使用sum函数计算dataframe单数据列的加和或者对所有的数据列进行求和(sum column or all columns of dataframe)
  2. 浅析Google技术底蕴
  3. java通过maven构建项目实现日志生成模拟(二)构建数据,FastJson方法的使用
  4. 提示虚拟内存不足的解决办法
  5. LVS原理介绍及安装过程
  6. 千万级分页存储过程结合Repeater+Aspnetpager7.2实现
  7. SpringBoot配置绑定的两种方式
  8. VMware 安装Ubuntu 无法进入安装界面
  9. Linux下安装flash player插件
  10. 全国智慧园区解决方案TOP50 | 附下载
  11. 计算机组装要哪些硬件,DIY组装电脑要买哪些硬件
  12. linux mono 安装
  13. 一组li或者div里面多个弹出层对应各自的内容
  14. ventory做U盘启动,使用vmware进行测试U盘系统盘是否制作成功
  15. 匀速贝塞尔曲线路径规划工具
  16. 无人机、手持全景设备、单反制作全景的基础流程,及全景成果与地图融合
  17. 核心单词Word List 40
  18. ASP.NET中的KRE是什么?
  19. flink 读取文件数据写入ElasticSearch
  20. 密码解码常用工具网站汇总

热门文章

  1. HOJ 2550 百步穿杨
  2. LeetCode-数据库题(二) (52-125题 到1565)
  3. 思科路由器无法访问互联网怎么操作?
  4. hibernate注解映射继承关系
  5. 【考研英语语法】被动语态练习题
  6. 下载神器 Proxyee Down windows10 安装教程
  7. 鹏城实验室开源技术总师余跃:新一代人工智能开源生态的探索与实践
  8. linux需要wifi网络认证,无线802.1x认证简介及配置方法
  9. Zimbra 8.7.11规则:只能发送内部邮件
  10. 计算机的扫雷如何恢复,电脑自带的蜘蛛纸牌被误删了如何找回