不能上網,利用光碟片安裝 gcc 和 gcc-c++的方法如下:
首先把光碟片放入光碟機內,虛擬機器內的話就用 iso 光碟片鏡像就可以了。
然後如下:
[root@localhost ~]# more gcc_install.sh
#!/bin/bash
mount /dev/cdrom /mnt
cd /mnt/CentOS/
rpm -ivh glibc-common-2.5-42.i386.rpm
rpm -ivh kernel-headers-2.6.18-164.el5.i386.rpm
rpm -ivh libgcc-4.1.2-46.el5.i386.rpm
rpm -ivh glibc-2.5-42.i686.rpm
rpm -ivh cpp-4.1.2-46.el5.i386.rpm
rpm -ivh libgomp-4.4.0-6.el5.i386.rpm
rpm -ivh nscd-2.5-42.i386.rpm
rpm -ivh glibc-headers-2.5-42.i386.rpm
rpm -ivh glibc-devel-2.5-42.i386.rpm
rpm -ivh gcc-4.1.2-46.el5.i386.rpm
echo "gcc is installed successful!!!"
rpm -ivh libstdc++-4.1.2-46.el5.i386.rpm
rpm -ivh libstdc++-devel-4.1.2-46.el5.i386.rpm
rpm -ivh gcc-c++-4.1.2-46.el5.i386.rpm
echo "gcc-c++ is installed successful!!!"
[root@localhost ~]# chmod +x gcc_install.sh
[root@localhost ~]# ./gcc_install.sh
mount: block device /dev/cdrom is write-protected, mounting read-only
warning: glibc-common-2.5-42.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing... ########################################### [100%]
package glibc-common-2.5-42.i386 is already installed
warning: kernel-headers-2.6.18-164.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing... ########################################### [100%]
1:kernel-headers ########################################### [100%]
warning: libgcc-4.1.2-46.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing... ########################################### [100%]
package libgcc-4.1.2-46.el5.i386 is already installed
warning: glibc-2.5-42.i686.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing... ########################################### [100%]
package glibc-2.5-42.i686 is already installed
warning: cpp-4.1.2-46.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing... ########################################### [100%]
package cpp-4.1.2-46.el5.i386 is already installed
warning: libgomp-4.4.0-6.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing... ########################################### [100%]
1:libgomp ########################################### [100%]
warning: nscd-2.5-42.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing... ########################################### [100%]
package nscd-2.5-42.i386 is already installed
warning: glibc-headers-2.5-42.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing... ########################################### [100%]
1:glibc-headers ########################################### [100%]
warning: glibc-devel-2.5-42.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing... ########################################### [100%]
1:glibc-devel ########################################### [100%]
warning: gcc-4.1.2-46.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing... ########################################### [100%]
1:gcc ########################################### [100%]
gcc is installed successful!!!
warning: libstdc++-4.1.2-46.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing... ########################################### [100%]
package libstdc++-4.1.2-46.el5.i386 is already installed
warning: libstdc++-devel-4.1.2-46.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing...