關於RedHat Linux沒法使用yum命令安裝gcc-c++問題

初入職場,在給RedHat Linux安裝環境的時候遇到這麼個問題。java

參考:http://www.linuxidc.com/Linux/2017-08/146548.htmlinux

[root@localhost ~]# yum -y install gcc
Loaded plugins: katello, product-id, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
Setting up Install Process
No package gcc available.
Nothing to donginx

對於習慣使用CentOS的人來講,不能使用這個命令,簡直是種折磨c++

解決過程:centos

1.給linux redhat安裝Centos鏡像緩存

[root@localhost~]# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
--2015-10-09 14:33:10-- http://mirrors.163.com/.help/CentOS6-Base-163.repo
Resolving mirrors.163.com... 123.58.173.186,123.58.173.185
Connecting to mirrors.163.com|123.58.173.186|:80...connected.
HTTP request sent, awaiting response... 200 OK
Length: 2341 (2.3K) [application/octet-stream]
Saving to: `CentOS6-Base-163.repo'
 
100%2,341      --.-K/s  in 0s    
 
2015-10-09 14:33:22 (108 MB/s) -`CentOS6-Base-163.repo' saved [2341/2341]app

2.修改repo文件ide

[root@localhost~]# mv CentOS6-Base-163.repo /etc/yum.repos.d/ui

*** 把$releasever替換成6
[root@localhost yum.repos.d]# sed -i 's#$releasever#6#g' ./CentOS6-Base-163.repourl

3.清除全部緩存

[root@localhost yum.repos.d]# yum clean all
Loaded plugins: katello, product-id, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
Cleaning up Everything

4.獲取yum列表

[root@localhost yum.repos.d]# yum makecache
Loaded plugins: katello, product-id, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
addons                                                                                                | 1.9 kB    00:00    
addons/filelists_db                                                                                    |  570 B    00:00    
........
........
base                                                                                                                3667/3667
base                                                                                                                3667/3667
base                                                                                                                3667/3667
Metadata Cache Created

5.搜索安裝

[root@localhost ~]# yum search gcc |grep --color '^gcc'
gcc.x86_64 : Various compilers (C, C++, Objective-C, Java, ...)
gcc-c++.x86_64 : C++ support for GCC
gcc-gfortran.x86_64 : Fortran 95 support
gcc-gnat.x86_64 : Ada 95 support for GCC
gcc-java.x86_64 : Java support for GCC
gcc-objc++.x86_64 : Objective-C++ support for GCC
gcc-objc.x86_64 : Objective-C support for GCC
gcc44.x86_64 : GNU Compiler Collection version 4.4
gcc44-c++.x86_64 : C++ support for GCC version 4.4
gcc44-gfortran.x86_64 : Fortran support for GCC 4.4

6.安裝gcc

[root@localhost yum.repos.d]# yum -y install gcc

至此,gcc安裝完成,而且對於其餘的編譯環境也能夠使用yum安裝了。

Linux升級GCC 4.8.1清晰簡明教程(Ubuntu 12.04 64位版爲例)  http://www.linuxidc.com/Linux/2014-04/99583.htm 

Ubuntu 14.04 LST安裝GCC 4.1.2  http://www.linuxidc.com/Linux/2016-06/132040.htm

Ubuntu下Vim+GCC+GDB安裝及使用 http://www.linuxidc.com/Linux/2013-01/78159.htm 

Ubuntu下兩個GCC版本切換 http://www.linuxidc.com/Linux/2012-10/72284.htm 

CentOS6.5升級手動安裝GCC4.8.2  http://www.linuxidc.com/Linux/2015-01/112595.htm 

Ubuntu升級GCC版本 http://www.linuxidc.com/Linux/2016-11/136840.htm

CentOS7環境下在/離線安裝GCC與GCC-C++  http://www.linuxidc.com/Linux/2017-03/142319.htm

Ubuntu 16.04 LTS 降級安裝GCC 4.8  http://www.linuxidc.com/Linux/2017-03/142299.htm

本文永久更新連接地址http://www.linuxidc.com/Linux/2017-08/146549.htm

轉自:https://www.linuxidc.com/Linux/2017-08/146549.htm

 

 

補充:最後仍是報錯,缺乏依賴

最終方案見下圖:

Pre-Built Packages for Mainline version

To set up the yum repository for RHEL/CentOS, create the file named /etc/yum.repos.d/nginx.repo with the following contents:

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/OS/OSRELEASE/$basearch/
gpgcheck=0
enabled=1

Replace 「OS」 with 「rhel」 or 「centos」, depending on the distribution used, and 「OSRELEASE」 with 「6」 or 「7」, for 6.x or 7.x versions, respectively.

在 /etc/yum.repos.d/ 目錄下新建 nginx.repo 文件 內容以下:

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/rhel/7/$basearch/
gpgcheck=0
enabled=1

 

 

而後 執行  yum install nginx 命令 

nginx 就安裝好了  

安裝在 /etc/nginx 下 只須要修改配置文件就行了   

相關文章
相關標籤/搜索