日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

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

發布時間:2023/12/8 linux 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Red Hat Enterprise Linux Server release 7.1 (Maipo) 安装gcc 的几种方式 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
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.rpmd. 安裝新的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 的几种方式的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。