How to Install Vagrant on CentOS 7


Vagrant is a software package that creates a standardized operating environment using virtualization technology.

Vagrant provides a command-line tool for loading and managing virtual operating systems. We will be using the VirtualBox provider in this tutorial.

This guide will walk you through installing Vagrant on CentOS 7.

how to install vagrant on centos7


Install Vagrant on CentOS

Step 1: Refresh Software Repositories

In a terminal window, enter the command:

sudo yum update

The package manager will reach out to the repositories and refresh the listings. This ensures you are loading the most recent and patched versions of the software.

Step 2: Install VirtualBox

Vagrant is a tool that allows you to run an operating system inside an operating system. It does this by creating a virtual environment. Vagrant relies on an outside app (like VirtualBox) to manage virtual environments.

1. Start by installing the dependencies for VirtualBox. Enter the following into a terminal window:

sudo yum –y install epel-release
sudo yum –y install gcc dkms make qt libgomp patch
sudo yum –y install kernel-headers kernel-devel binutils glibc-headers glibc-devel font-forge

2. Next, add the software repository for VirtualBox:

sudo cd /etc/yum.repo.d/
sudo wget

3. Install the VirtualBox software:

sudo yum –y install VirtualBox-5.2

4. Verify that VirtualBox is installed with the command:


The system should launch a new window welcoming you to VirtualBox.

There are other virtualization applications available. If you prefer, you could use KVM, VMware, or any other type of hypervisor software.

Note: If you opted to go with KVM, please refer to our tutorial on How To Install KVM on CentOS.

Step 3: Install Vagrant on CentOS

1. Open a web browser and browse to This page contains the most recent version of the software. At the time this article was written, Vagrant is at version 2.2.2.

2. In a terminal window, download the installation package by entering:

sudo wget

The system should download the installation file. Adjust the version number and system architecture (32- or 64-bit) as needed for your system.

3. Install Vagrant on your CentOS machine with the command:

sudo yum –y localinstall vagrant_2.2.2_x86_64.rpm

Step 4: Verify Installation

To verify successful installation, display the version of Vagrant with the following command:

vagrant ––version

This is a quick way to make sure that the installation completed successfully. If you omit the double-hyphen, it will also include the latest available version.

Get Started With Vagrant on CentOS

1. To get started, you’ll need to create a directory to store your Vagrant files. In a terminal window, enter:

sudo mkdir ~/vagrant-centos-7

2. Switch to that directory with the command:

cd ~/vagrant-centos-7

3. Next, load a Vagrant box that you want to use. As an example, we’ll load a CentOS 7 file:

vagrant box add centos/7

4. Next, create a simple Vagrantfile. This is a text file with instructions for Vagrant to build out the virtual machine you want. Enter the command:

touch Vagrantfile

This should create a file Vagrantfile in the directory ~/vagrant-centos-7.

5. You can then launch the CentOS 7 virtual machine by entering:

vagrant up

The system should respond by telling you a “Vagrantfile” has been placed in the directory.

Note: You can also use the vagrant init command to initialize a virtual machine. The init command checks for a Vagrant file and creates one if not found. This can save you a couple of steps, especially if you’re running a default configuration. Use the init command after you create and switch to a directory. The init command is vagrant init centos/7

Basic Vagrant Commands

To create a virtual machine based on this file, enter:

vagrant up

The system will respond by displaying the default SSH address, username, and authentication method for the virtual machine it just created.

You can connect to your new virtual machine using SSH:

vagrant ssh

You can now work in a virtual CentOS 7 environment.

To stop your virtual machine use the command:

vagrant halt

To delete the virtual machine you just created, use the destroy command.

vagrant destroy

This will delete everything you’ve done inside that virtual machine.


Now, you know how to install and configure Vagrant on your CentOS 7 machine. Enjoy your new virtualized server!

Typically, this tool is used to duplicate an exact working environment. This can be particularly useful to a software development team to ensure code compatibility. For more information about Vagrant usage, please see the official Vagrant documentation site.

Was this article helpful?
Goran Jevtic
Goran combines his leadership skills and passion for research, writing, and technology as a Technical Writing Team Lead at phoenixNAP. Working with multiple departments and on various projects, he has developed an extraordinary understanding of cloud and virtualization technology trends and best practices.
Next you should read
Vagrant Tutorial: Everything a Beginner Needs To Know
April 17, 2019

Vagrant is a tool for configuring and deploying an exact image of a virtual operating system. It is often...
Read more
How to Install Vagrant on Ubuntu 18.04
September 4, 2023

Vagrant is a software application that creates an operating system environment using virtualization...
Read more
How to use apt Package Manager on Ubuntu Linux
January 7, 2019

In Linux, special tools were developed for managing applications. Application software for Linux typically...
Read more
How to Install phpMyAdmin on CentOS 7
October 22, 2018

This guide is for users who have already configured a CentOS server and installed the Apache HTTP services...
Read more