How to set up a virtual machine with VirtualBox for local testing

This article describes how to install and configure a virtual machine using VirtualBox, a popular virtualization application. VirtualBox runs on Windows, Mac OS X, and Linux, and features an easy-to-use graphical user interface for creating and managing virtual machines.

About virtual machines

Virtual machines emulate a computer—they enable you to install an entire operating system within an existing operating system. The virtual machine runs in its own “sandbox,” safely isolated from the host operating system. Because of this isolation, virtual machines enable you to safely test new features, applications, and configurations without having to worry about harming your existing operating system.

By creating a virtual machine with a configuration that closely matches A2 Hosting's servers, you can safely do testing and development work on your own computer before you roll out the changes to a live site.

Installing VirtualBox

Before you can create a virtual machine, you must first install the VirtualBox application on your computer. To do this, follow the appropriate procedure for the operating system that is installed on your computer:

VirtualBox on Windows

To install VirtualBox on a Windows-based computer, follow these steps:

  1. On your local computer, use your web browser to go to https://www.virtualbox.org/wiki/Downloads.
  2. Click Windows hosts, and then download the .exe file to your computer.
  3. Run the .exe file to start the installation.
  4. Click Next.
  5. Follow the prompts to complete the installation.
VirtualBox on Mac OS X

To install VirtualBox on a Mac OS X-based computer, follow these steps:

  1. On your local computer, use your web browser to go to https://www.virtualbox.org/wiki/Downloads.
  2. Click OS X hosts, and then download the .dmg file to your computer.
  3. Double-click the .dmg file to start the installation.
  4. Follow the prompts to complete the installation.
Virtual Box on Linux

To install VirtualBox on a Linux-based computer, follow these steps:

  1. On your local computer, use your web browser to go to https://www.virtualbox.org/wiki/Downloads.
  2. Click Linux distributions.
  3. Download the appropriate package file for the Linux distribution your computer uses.
  4. Use your Linux distribution's package manager to install the package file.

Creating a virtual machine and installing an operating system

At this point, you have installed the VirtualBox application on your computer, but you still need to create a virtual machine. To do this, you specify the virtual machine's settings, and then install an operating system on it.

The following procedures demonstrate how to create a new virtual machine and install CentOS 7 on it. Many A2 Hosting servers run CentOS 7, so it is a good choice for your first virtual machine.

Creating a new virtual machine

To create a new virtual machine, follow these steps:

  1. Start VirtualBox.
  2. On the Machine menu, click New.
  3. In the Name text box, type CentOS 7. VirtualBox should automatically detect CentOS, and select Linux in the Type list box, and Red Hat in the Version list box.
  4. Click Next.
  5. In the Memory Size dialog box, select the amount of RAM you want to allocate to the virtual machine, and then click Next.
    The more RAM your computer has, the more RAM you can safely allocate to the virtual machine. As a general rule, however, you should have at least 512 MB of free RAM to run a Linux virtual machine.
  6. In the Hard disk dialog box, select Create a virtual hard disk now, and then click Create.
  7. In the Hard disk file type dialog box, select VDI (VirtualBox Disk Image), and then click Next.
  8. In the Storage on physical hard disk dialog box, select Dynamically allocated, and then click Next.
  9. In the File location and size dialog box, type a name for the virtual hard disk file, select the size of the hard disk, and then click Create.
    The more disk space your computer has, the more space you can safely allocate to the virtual machine's hard disk. As a general rule, however, you should have at least 5 GB of free disk space for a Linux virtual machine.
Installing an operating system

After you create the virtual machine, you are ready to install an operating system on it. To install CentOS 7, follow these steps:

  1. Use your web browser to go to https://www.centos.org/download.
  2. Click Minimal ISO, and then save the .iso file to your local computer.
  3. In VirtualBox, select the virtual machine you created in the previous procedure, and then click Start.
  4. In the Select start-up disk dialog box, click the folder icon.
  5. In the file selection dialog box, locate and select the .iso file you downloaded in step 2, and then click Start. VirtualBox boots the virtual machine using the .iso CD image file.
  6. On the CentOS 7 installation page, select Install CentOS 7.
  7. On the Welcome to CentOS 7 page, select the language you want to use for the installation process, and then click Continue.
  8. On the Installation Summary page, complete any items marked with the yellow triangular warning icon, and then click Begin Installation.
    During installation, you can (and should) set the root password and create a regular user.
  9. Follow the remaining prompts to complete the installation.
  10. After installation is complete, click Reboot to restart the virtual machine. You now have a fully-functioning CentOS 7 installation on your local computer.

More Information

For more information about VirtualBox, please visit https://www.virtualbox.org.

Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.

We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.