Method 1: yum install gcc
Method 2: Use the local iso file when you cannot access the Internet
a. ftp upload the iso installation file to /usr/local/src
b. Create a new /media/CentOS, mount the iso file to /media/CentOS
mount -t iso9660 -o loop /usr/local/src/CentOS-7-x86_64-DVD-1511.iso /media/CentOS
c. Set the system image file to be automatically mounted at startup
mount -l
d. Back up the /etc/yum.repos.d/CentOS-Base.repo file and create a new CentOS-Base.repo file
[root@localhost yum.repos.d]# cp CentOS-Base.repo CentOS-Base.repo.bak
[root@localhost yum.repos.d]# vi CentOS-Base.repo
[centos7]
name=CentOS-$releasever - centos7
baseurl = file: /// media/CentOS
gpgcheck=0
enabled=1
e. Install gcc
[root@localhost yum.repos.d]# yum clean all
[root@localhost yum.repos.d]# yum install gcc