在一個新的Linux服務器上安裝nginx的時候,命令都不能解析,缺少gcc編輯器,安裝gcc的命令也出錯。
[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 do
沒有gcc的軟件包的,最終找到一個解決辦法!
檢查版本:這一步是從鏡像網站中取相關版本文件用的。
[root@localhost ~]# cat /etc/issue Red Hat Enterprise Linux Server release 6.9 (Tikanga) Kernel \r on an \m
解決過程:
1,從阿里鏡像網站下載文件repo文件:https://opsx.alibaba.com/mirror
按照阿里幫助文檔操作即可。
[root@bogon yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo --2019-02-02 22:28:12-- http://mirrors.aliyun.com/repo/Centos-6.repo Resolving mirrors.aliyun.com... 163.177.119.232, 163.177.119.231, 163.177.119.233, ... Connecting to mirrors.aliyun.com|163.177.119.232|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 2523 (2.5K) [application/octet-stream] Saving to: “/etc/yum.repos.d/CentOS-Base.repo” 100%[=============================================================================>] 2,523 --.-K/s in 0s 2019-02-02 22:28:12 (170 MB/s) - “/etc/yum.repos.d/CentOS-Base.repo” saved [2523/2523]
2.修改repo文件(根據紅帽版本) *** 把$releasever替換成5 (紅帽6版本以上的改為6)
[root@bogon yum.repos.d]# sed -i 's#$releasever#6#g' ./CentOS-Base.repo
3.清除原有緩存
[root@bogon yum.repos.d]# yum clean all Loaded plugins: fastestmirror, refresh-packagekit, security Repository base is listed more than once in the configuration Repository updates is listed more than once in the configuration Repository extras is listed more than once in the configuration Repository centosplus is listed more than once in the configuration Repository contrib is listed more than once in the configuration Cleaning repos: addons base extras updates Cleaning up Everything Cleaning up list of fastest mirrors
4.獲取yum列表
[root@bogon yum.repos.d]# yum makecache Loaded plugins: fastestmirror, refresh-packagekit, security Repository base is listed more than once in the configuration Repository updates is listed more than once in the configuration Repository extras is listed more than once in the configuration Repository centosplus is listed more than once in the configuration Repository contrib is listed more than once in the configuration Determining fastest mirrors * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com http://mirrors.163.com/centos/6/addons/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found" Trying other mirror. To address this issue please refer to the below knowledge base article https://access.redhat.com/articles/1320623 If above article doesn't help to resolve this issue please open a ticket with Red Hat Support. Error: Cannot retrieve repository metadata (repomd.xml) for repository: addons. Please verify its path and try again [root@bogon yum.repos.d]# yum makecache Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com base | 3.7 kB 00:00 base/group_gz | 242 kB 00:00 base/filelists_db | 6.4 MB 00:12 base/primary_db | 4.7 MB 00:09 base/other_db | 2.8 MB 00:05 extras | 3.4 kB 00:00 extras/filelists_db | 24 kB 00:00 extras/prestodelta | 1.1 kB 00:00 extras/primary_db | 27 kB 00:00 extras/other_db | 28 kB 00:00 updates | 3.4 kB 00:00 updates/filelists_db | 2.0 MB 00:02 updates/prestodelta | 104 kB 00:00 updates/primary_db | 3.0 MB 00:05 updates/other_db | 42 MB 01:27 Metadata Cache Created
5.搜索安裝
[root@bogon yum.repos.d]# yum search gcc |grep --color '^gcc' gcc-c++.x86_64 : C++ support for GCC 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 gcc.x86_64 : Various compilers (C, C++, Objective-C, Java, ...) gcc-gfortran.x86_64 : Fortran support
6.安裝gcc
[root@bogon yum.repos.d]# yum install -y gcc gcc-c++ Loaded plugins: fastestmirror, refresh-packagekit, security Setting up Install Process Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Resolving Dependencies --> Running transaction check ---> Package gcc.x86_64 0:4.4.7-23.el6 will be installed --> Processing Dependency: libgomp = 4.4.7-23.el6 for package: gcc-4.4.7-23.el6.x86_64 --> Processing Dependency: cpp = 4.4.7-23.el6 for package: gcc-4.4.7-23.el6.x86_64 --> Processing Dependency: libgcc >= 4.4.7-23.el6 for package: gcc-4.4.7-23.el6.x86_64 --> Processing Dependency: cloog-ppl >= 0.15 for package: gcc-4.4.7-23.el6.x86_64 ---> Package gcc-c++.x86_64 0:4.4.7-23.el6 will be installed --> Processing Dependency: libstdc++-devel = 4.4.7-23.el6 for package: gcc-c++-4.4.7-23.el6.x86_64 --> Processing Dependency: libstdc++ = 4.4.7-23.el6 for package: gcc-c++-4.4.7-23.el6.x86_64 --> Processing Dependency: libmpfr.so.1()(64bit) for package: gcc-c++-4.4.7-23.el6.x86_64 --> Running transaction check ---> Package cloog-ppl.x86_64 0:0.15.7-1.2.el6 will be installed --> Processing Dependency: libppl_c.so.2()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64 --> Processing Dependency: libppl.so.7()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64 ---> Package cpp.x86_64 0:4.4.7-23.el6 will be installed ---> Package libgcc.x86_64 0:4.4.7-18.el6 will be updated ---> Package libgcc.x86_64 0:4.4.7-23.el6 will be an update ---> Package libgomp.x86_64 0:4.4.7-18.el6 will be updated ---> Package libgomp.x86_64 0:4.4.7-23.el6 will be an update ---> Package libstdc++.x86_64 0:4.4.7-18.el6 will be updated ---> Package libstdc++.x86_64 0:4.4.7-23.el6 will be an update ---> Package libstdc++-devel.x86_64 0:4.4.7-23.el6 will be installed ---> Package mpfr.x86_64 0:2.4.1-6.el6 will be installed --> Running transaction check ---> Package ppl.x86_64 0:0.10.2-11.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================= Package Arch Version Repository Size ======================================================================================================================= Installing: gcc x86_64 4.4.7-23.el6 base 10 M gcc-c++ x86_64 4.4.7-23.el6 base 4.7 M Installing for dependencies: cloog-ppl x86_64 0.15.7-1.2.el6 base 93 k cpp x86_64 4.4.7-23.el6 base 3.7 M libstdc++-devel x86_64 4.4.7-23.el6 base 1.6 M mpfr x86_64 2.4.1-6.el6 base 157 k ppl x86_64 0.10.2-11.el6 base 1.3 M Updating for dependencies: libgcc x86_64 4.4.7-23.el6 base 104 k libgomp x86_64 4.4.7-23.el6 base 135 k libstdc++ x86_64 4.4.7-23.el6 base 296 k Transaction Summary ======================================================================================================================= Install 7 Package(s) Upgrade 3 Package(s) Total download size: 22 M Downloading Packages: (1/10): cloog-ppl-0.15.7-1.2.el6.x86_64.rpm | 93 kB 00:00 (2/10): cpp-4.4.7-23.el6.x86_64.rpm | 3.7 MB 00:06 (3/10): gcc-4.4.7-23.el6.x86_64.rpm | 10 MB 00:21 (4/10): gcc-c++-4.4.7-23.el6.x86_64.rpm | 4.7 MB 00:10 (5/10): libgcc-4.4.7-23.el6.x86_64.rpm | 104 kB 00:00 (6/10): libgomp-4.4.7-23.el6.x86_64.rpm | 135 kB 00:00 (7/10): libstdc++-4.4.7-23.el6.x86_64.rpm | 296 kB 00:00 (8/10): libstdc++-devel-4.4.7-23.el6.x86_64.rpm | 1.6 MB 00:03 (9/10): mpfr-2.4.1-6.el6.x86_64.rpm | 157 kB 00:00 (10/10): ppl-0.10.2-11.el6.x86_64.rpm | 1.3 MB 00:02 ----------------------------------------------------------------------------------------------------------------------- Total 495 kB/s | 22 MB 00:45 warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY Retrieving key from http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6 Importing GPG key 0xC105B9DE: Userid: "CentOS-6 Key (CentOS 6 Official Signing Key) <centos-6-key@centos.org>" From : http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Updating : libgcc-4.4.7-23.el6.x86_64 1/13 Updating : libstdc++-4.4.7-23.el6.x86_64 2/13 Installing : mpfr-2.4.1-6.el6.x86_64 3/13 Installing : cpp-4.4.7-23.el6.x86_64 4/13 Installing : libstdc++-devel-4.4.7-23.el6.x86_64 5/13 Installing : ppl-0.10.2-11.el6.x86_64 6/13 Installing : cloog-ppl-0.15.7-1.2.el6.x86_64 7/13 Updating : libgomp-4.4.7-23.el6.x86_64 8/13 Installing : gcc-4.4.7-23.el6.x86_64 9/13 Installing : gcc-c++-4.4.7-23.el6.x86_64 10/13 Cleanup : libstdc++-4.4.7-18.el6.x86_64 11/13 Cleanup : libgcc-4.4.7-18.el6.x86_64 12/13 Cleanup : libgomp-4.4.7-18.el6.x86_64 13/13 Verifying : libgomp-4.4.7-23.el6.x86_64 1/13 Verifying : gcc-c++-4.4.7-23.el6.x86_64 2/13 Verifying : gcc-4.4.7-23.el6.x86_64 3/13 Verifying : mpfr-2.4.1-6.el6.x86_64 4/13 Verifying : cloog-ppl-0.15.7-1.2.el6.x86_64 5/13 Verifying : libstdc++-4.4.7-23.el6.x86_64 6/13 Verifying : cpp-4.4.7-23.el6.x86_64 7/13 Verifying : libstdc++-devel-4.4.7-23.el6.x86_64 8/13 Verifying : ppl-0.10.2-11.el6.x86_64 9/13 Verifying : libgcc-4.4.7-23.el6.x86_64 10/13 Verifying : libgomp-4.4.7-18.el6.x86_64 11/13 Verifying : libgcc-4.4.7-18.el6.x86_64 12/13 Verifying : libstdc++-4.4.7-18.el6.x86_64 13/13 Installed: gcc.x86_64 0:4.4.7-23.el6 gcc-c++.x86_64 0:4.4.7-23.el6 Dependency Installed: cloog-ppl.x86_64 0:0.15.7-1.2.el6 cpp.x86_64 0:4.4.7-23.el6 libstdc++-devel.x86_64 0:4.4.7-23.el6 mpfr.x86_64 0:2.4.1-6.el6 ppl.x86_64 0:0.10.2-11.el6 Dependency Updated: libgcc.x86_64 0:4.4.7-23.el6 libgomp.x86_64 0:4.4.7-23.el6 libstdc++.x86_64 0:4.4.7-23.el6 Complete!
結束語:當別人曾經解決過的問題,以后不一定適用,需要根據問題分析原因,再進行甄別和篩選!
參考他們說明,再進行修改得來,僅供大家參考!
http://www.openskill.cn/article/126
https://www.cnblogs.com/sunjiguang/p/5970217.html