It's not so easy on CentOS, but it can be done using yum. To start, you need to open up terminal and switch to the root user. This is pretty straightforward with:
su -
or
sudo -i
then enter the root password. The next step is to add the RHEL repos.
wget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo
then
yum update
Once the update is complete, perform a reboot.
CentOS 5/6/7 need the EPEL repo in addition to the RHEL repos, the commands for that are here:
## CentOS 7 and RHEL 7 ##
rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-6.noarch.rpm
## CentOS 6 and RHEL 6 ##
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
## CentOS 5 and RHEL 5 ##
rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
Perform another repo update with
yum update
Next, there are a few prereqrisites that need to be installed before downloading and installing VirtualBox.
yum install binutils gcc make patch libgomp glibc-headers glibc-devel kernel-headers kernel-devel dkms
Then install VirtualBox with:
yum install VirtualBox-5.0
This command automatically creates the vboxusers group and your username must be a part of that group in order for VirtualBox to work. Replace username with your regular username
usermod -a -G vboxusers username
Rebuild the kernel modules for VirtualBox to run:
## CentOS/RHEL 7 ##
/usr/lib/virtualbox/vboxdrv.sh setup
## CentOS/RHEL 6/5 ##
/etc/init.d/vboxdrv setup
If everything went well, you should now be able to launch VirtualBox from either the terminal by typing VirtualBox or by clicking on the icon in the application launcher. Be sure to check the BIOS for enabling Virtualization Support. This wasn't enabled on my desktop at first and VirtualBox wouldn't allow to start any VM's without it enabled.