1.进入virtualbox官网
https://www.virtualbox.org/
2.点击download
3.点击Linux distributions
4.向下翻至如图,并且进入同种框选页面
5.在/etc/yum.repos.d/目录下新建virtualbox.repo并写入如下内容
[virtualbox] name=Oracle Linux / RHEL / CentOS-$releasever / $basearch - VirtualBox baseurl=http://download.virtualbox.org/virtualbox/rpm/el/$releasever/$basearch enabled=1 gpgcheck=1 repo_gpgcheck=1 gpgkey=https://www.virtualbox.org/download/oracle_vbox.asc
6.更新yum缓存
yum clean all
yum makecache
7.安装virtualbox
yum install VirtualBox-5.1