Learn how to install Vagrant on CentOS 7 with this step-by-step guide. Easily set up your development environment with Vagrant on CentOS 7. #centlinux #linux #vagrant #virtualbox
Table of Contents
What is Vagrant?
Vagrant is an open-source software for easy provisioning of virtual software development environments. The virtual environments called Vagrant boxes are portable in nature and can be used over many platforms without any change. Vagrant is developed by HashiCorp and distributed under MIT License. Vagrant leverages a declarative configuration file which describes all your software requirements, packages, operating system configuration, users, and more.
In this article, we will install Vagrant on CentOS 7 along with VirtualBox. At first, we will install VirtualBox as the provider for Vagrant software, then we will install Vagrant on CentOS 7.
Read Also: How to install Vagrant with KVM on CentOS 8
Vagrant Features
- Create complex virtual development environments in a single workflow.
- Portal development environments, that can be moved to other machines conveniently.
- Starts a desired development environment with just a single command.
- A same vagrantfile can be used by all developers to provision their own development environments.
- Users can create their own custom Vagrant Box or select from the globally available Vagrant boxes of popular software.
- Easy and Fast.

Vagrant Architecture
Vagrant uses Provisioners and Providers as building blocks to create and manage the development environments.
- Provisioners are tools to customize the virtual environments e.g. Puppet, Chef, Ansible, etc.
- Providers are the services that Vagrant uses to setup and create virtual environments e.g. VirtualBox, Docker, Hyper-V, etc.
Vagrant creates a layer on top of the virtualization software and allow the users to manager development environments with just a single vagrant command. Machine and software requirements are defined in vagrantfile, to execute necessary steps to create a development-ready box.
Box is a format and an extension (.box) for Vagrant environments, and it is portable across various platforms.
Vagrant System Requirements
Vagrant has no special hardware and software requirements except that it requires a Provider to create development environments.
Recommended Training: Vagrant Up! Comprehensive development system automation from Jason Taylor, John Myers

Linux Server Specification
We have provisioned a CentOS 7 based system with following specifications:
- Hostname – vagrant-01.example.com
- IP Address – 192.168.116.176 /24
- Operating System – CentOS 7.6
- CPU – 3.4 Ghz (2 Core)
- Memory – 2 GB
- Storage – 20 GB
Install VirtualBox on CentOS 7
Connect with vagrant-01.example.com using ssh as root user.
Install prerequisite software packages using yum command.
yum install -y kernel-devel-$(uname -r) kernel-headers gcc make perl wget
We have used $(uname -r) with above yum command. It demands a little clarification.
The vboxdrv.service requires same kernel-devel modules as of running Kernel. Otherwise, after installation vboxdrv.service will give you following errors.
tail /var/log/messages
Output:
Jun 16 11:22:05 vagrant-01 vboxdrv.sh: Building VirtualBox kernel modules.
Jun 16 11:22:06 vagrant-01 vboxdrv.sh: This system is currently not set up to build kernel modules.
Jun 16 11:22:06 vagrant-01 vboxdrv.sh: Please install the Linux kernel "header" files matching the current kernel
Jun 16 11:22:06 vagrant-01 vboxdrv.sh: for adding new hardware support to the system.
Jun 16 11:22:06 vagrant-01 vboxdrv.sh: The distribution packages containing the headers are probably:
Jun 16 11:22:06 vagrant-01 vboxdrv.sh: kernel-devel kernel-devel-3.10.0-957.el7.x86_64
Jun 16 11:22:06 vagrant-01 systemd: vboxdrv.service: control process exited, code=exited status=1
Jun 16 11:22:06 vagrant-01 systemd: Failed to start VirtualBox Linux kernel module.
Jun 16 11:22:06 vagrant-01 systemd: Unit vboxdrv.service entered failed state.
Jun 16 11:22:06 vagrant-01 systemd: vboxdrv.service failed.
Therefore, we have used $(uname -r) command to suffix the Kernel version with the yum command for the desired result.
VirtualBox is a free and open-source Hypervisor, developed by Oracle Corporation.
VirtualBox’s yum repository configurations are available at VirtualBox Official Website.
Therefore, we will first add VirtualBox’s yum repository in our CentOS 7 server and then we will install VirtualBox using yum command.
First of all, we have to import Oracle public key in our CentOS 7 server.
Download Oracle public key as follows.
cd /tmp
wget https://www.virtualbox.org/download/oracle_vbox.asc
Import Oracle public key in our CentOS 7 server.
rpm --import oracle_vbox.asc
Download and add VirtualBox yum repository in our CentOS 7 server.
wget https://download.virtualbox.org/virtualbox/rpm/el/virtualbox.repo -O /etc/yum.repos.d/virtualbox.repo
Build yum cache for newly added repositories.
yum makecache fast
Install VirtualBox on CentOS 7 using yum command.
yum install -y VirtualBox-6.0
vboxdrv.service is automatically enabled and started by VirtualBox installation process.
Check status of vboxdrv.service.
systemctl status vboxdrv.service
Output:
â vboxdrv.service - VirtualBox Linux kernel module
Loaded: loaded (/usr/lib/virtualbox/vboxdrv.sh; enabled; vendor preset: disabled)
Active: active (exited) since Sun 2019-06-16 11:28:47 PKT; 10min ago
Process: 39778 ExecStart=/usr/lib/virtualbox/vboxdrv.sh start (code=exited, status=0/SUCCESS)
Jun 16 11:27:27 vagrant-01.example.com systemd[1]: Starting VirtualBox Linux ...
Jun 16 11:27:27 vagrant-01.example.com vboxdrv.sh[39778]: vboxdrv.sh: Startin...
Jun 16 11:27:27 vagrant-01.example.com vboxdrv.sh[39778]: vboxdrv.sh: Buildin...
Jun 16 11:28:47 vagrant-01.example.com systemd[1]: Started VirtualBox Linux k...
Hint: Some lines were ellipsized, use -l to show in full.
TP-Link Archer BE6500 Dual-Band Wi-Fi 7 Router (Archer BE400) | Dual 2.5 Gbps Ports USB 3.0 | Covers up to 2,400 Sq. ft and 90 Devices | Quad-core CPU| HomeShield, Private IoT for Network Security
19% OffInstall VirtualBox Extension Pack
VirtualBox is split into two components.
- Base Package
- Extension Packs
We have already installed VirtualBox Base Package above. Now, we are installing VirtualBox Extension Pack to extend the functionality of VirtualBox software.
VirtualBox Extension Pack is available at VirtualBox Official Website.
There is a single universal package of VirtualBox Extension Pack available that supports all platforms.
Therefore, we are downloading it using wget command.
wget https://download.virtualbox.org/virtualbox/6.0.8/Oracle_VM_VirtualBox_Extension_Pack-6.0.8.vbox-extpack
Install VirtualBox Extension Pack using VBoxManage command.
VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-6.0.8.vbox-extpack
Output:
VirtualBox Extension Pack Personal Use and Evaluation License (PUEL)
License version 10, 20 July 2017
...
...
...
Do you agree to these license terms and conditions (y/n)? y
License accepted. For batch installation add
--accept-license=56be48f923303c8cababb0bb4c478284b688ed23f16d775d729b89a2e8e5f9eb
to the VBoxManage command line.
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Successfully installed "Oracle VM VirtualBox Extension Pack".
VirtualBox 6.0 and VirtualBox Extension Pack have been successfully installed on CentOS 7 server.
Install Vagrant on CentOS 7
To install Vagrant on CentOS 7, we need to install following prerequisite packages.
yum install -y rsync
Latest version of Vagrant is available on Vagrant Official Download Page.
Download Vagrant RPM using wget command.
wget https://releases.hashicorp.com/vagrant/2.2.4/vagrant_2.2.4_x86_64.rpm
Install Vagrant on CentOS 7 by using rpm command.
rpm -ivh vagrant_2.2.4_x86_64.rpm
Create a home directory to store Vagrant projects.
mkdir ~/vagrant-home
cd ~/vagrant-home/
Create a new project directory and create a vagrantfile therein for Alpine Linux.
mkdir alpine
cd alpine
vagrant init generic/alpine38
Output:
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
We have initialized a new Vagrant project with generic/alpine38 vagrant box.
You can find a Vagrant box as per your choice of operating system and application software at Discover Vagrant Boxes.
Start the Vagrant Project using vagrant command.
vagrant up
Output:
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'generic/alpine38' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0
==> default: Loading metadata for box 'generic/alpine38'
default: URL: https://vagrantcloud.com/generic/alpine38
==> default: Adding box 'generic/alpine38' (v1.9.14) for provider: virtualbox
default: Downloading: https://vagrantcloud.com/generic/boxes/alpine38/versions/1.9.14/providers/virtualbox.box
default: Download redirected to host: vagrantcloud-files-production.s3.amazonaws.com
==> default: Successfully added box 'generic/alpine38' (v1.9.14) for 'virtualbox'!
==> default: Importing base box 'generic/alpine38'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'generic/alpine38' version '1.9.14' is up to date...
==> default: Setting the name of the VM: alpine_default_1560671657772_73973
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 (guest) => 2200 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
Disarming Code: System Programming, Debugging & Reverse Engineering in Linux, Android, Darwin
(as of May 28, 2025 17:27 GMT +00:00 – More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Final Thoughts
Installing Vagrant on CentOS 7 provides a powerful way to automate and manage virtual machine environments with ease. In this guide, we covered downloading the official Vagrant package, installing it on your system, and verifying that it works correctly.
With Vagrant set up, you can now quickly deploy and manage development environments, improving workflow efficiency and consistency. For best results, keep both Vagrant and your virtualization provider updated, and explore Vagrant plugins to further enhance your automation capabilities.
Need expert AWS and Linux system administration? From cloud architecture to server optimization, I provide reliable and efficient solutions tailored to your needs. Hire me on Fiverr today!
Leave a Reply
You must be logged in to post a comment.