Skip to content

Instantly share code, notes, and snippets.

@nuhil
Last active November 2, 2017 19:30
Show Gist options
  • Save nuhil/6096869ba88db6bca245 to your computer and use it in GitHub Desktop.
Save nuhil/6096869ba88db6bca245 to your computer and use it in GitHub Desktop.
Creating Virtual Machine with Vagrant Box

#Creating Virtual Machine with Vagrant Box
Step 1. Install VirtualBox and Vagrant in your main computer.

Step 2. Download a vagrant box from here and save anywhere in your main computer. To have a Ubuntu 14.04 64 bit Download.

Step 3. Add the newly downloaded box to your vagrant
vagrant box add NEWNAME PATH/SAVEDNAME
Here, NEWNAME is anything of your choice. Like, Ubuntu-14-04-64. PATH/SAVEDNAME is where you downloaded the vagrant box (path along with file name).

Step 4. Go to the location where you want to create a Vagrant Virtual Machine
cd /path/to/my/virtual-machine/folder

Step 5. Initialise Vagrant here
vagrant init NEWNAME

Step 6. To launch/Turn On the virtual machine, enter command
vagrant up

Step 7. To enter into the new virtual machine, issue the command
vagrant ssh

Step 8. To logout from that virtual machine
$ exit

Extra Step: To make the virtual machine sleep
vagrant suspend

Extra Step: To turn of a virtual machine
vagrant halt

Step 9. After exit ing, you go back to the /path/to/my/virtual-machine/folder location

Step 10. To edit the configuration of the virtual machine, edit the Vagrantfile file that is located here
sudo vi Vagrantfile

Step 11. To turn on the virtual machine again with new config
vagrant reload

Extra Step: To delete the virtual machine along with its inner file system
vagrant destroy

Important: To synch a folder form the main(host) machine to some where in the virtual machine, edit the vagrant file. Uncomment the line that looks like
config.vm.synced_folder "~/Documents/LAMP", "/var/www/html"
Here I am synching files from inside my Documents/LAMP folder to virtual machine's Apache root directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment