Update the system to the latest version.
yum update
Reboot the system.
reboot
Once the system is up, install header and development tools.
yum install -y kernel-devel kernel-headers gcc make perl
Also, install the wget package to download items using the terminal.
yum -y install wget
Download the Oracle public key.
wget https://www.virtualbox.org/download/oracle_vbox.asc
Import Oracle public key.
rpm --import oracle_vbox.asc
Download the VirtualBox repository file for CentOS 7 / RHEL 7 and move it into /etc/yum.repos.d/
directory.
wget http://download.virtualbox.org/virtualbox/rpm/el/virtualbox.repo -O /etc/yum.repos.d/virtualbox.repo
OR
Create the /etc/yum.repos.d/virtualbox.repo
file with the following repository information.
[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
Install VirtualBox using the yum
command.
VirtualBox v6.0:
yum install -y VirtualBox-6.0
VirtualBox v5.2:
yum install -y VirtualBox-5.2
Run the below command to check the status of VirtualBox Linux kernel module service.
systemctl status vboxdrv