MEAN Stack Development with Vagrant
- Introduction
- Vagrant provides easy to configure, reproducible, and portable work environments built on top of industry-standard technology and controlled by a single consistent workflow to help maximize the productivity and flexibility of you and your team.
- To achieve its magic, Vagrant stands on the shoulders of giants. Machines are provisioned on top of VirtualBox, VMware, AWS, or any other provider. Then, industry-standard provisioning tools such as shell scripts, Chef, or Puppet, can be used to automatically install and configure software on the machine.
- Setup Virtualbox
You have to completely remove older VirtualBox versions before
installing VirtualBox-5.0 !
- Display Allready Installed Packages
- sudo dpkg -l | grep virtualbox
- Uninstall VirtualBox
- sudo apt-get purge "^virtualbox-.*"
Update the software repositories
- sudo apt-get update
- Clean up
- sudo apt-get autoremove | sudo apt-get autoclean | sudo apt-get clean
- Setup API repository (For Ubuntu 14.04 ("Trusty"))
- echo "deb http://download.virtualbox.org/virtualbox/debian trusty contrib" | sudo tee /etc/apt/sources.list.d/oracle-vbox.list
- Setup Oracle Key
- wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
- wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -
- Install Oracle Virtualbox
- sudo apt-get update
- sudo apt-get install virtualbox-5.1
- Start Virtualbox
- virtualbox
- Vagrant Setup
- Once the above step is done, we will download Vagrant. You can head to their download page and download an appropriate version for your OS.
- Common Vagrant command are as follows
- vagrant box list #List all Vagrant boxes installed on your machine
- vagrant init xxx #Adds a new Vagrant box with the name xxx
- vagrant up #Boots the Vagrant box
- vagrant ssh #Connect to the Vagrant box via SSH
- vagrant reload #If you have updated the Vagrantfile, you need to reload the VM to reflect the changes. This commands does precisely that.
- vagrant halt #Stops the Vagrant box
- vagrant destroy #Remove the Vagrant instance from your machine (All data in the VM will be lost)
Create a custom MEAN Stack Vagrant box
- The first step in configuring any Vagrant project is to create a Vagrantfile. The purpose of the Vagrantfile is :
- Mark the root directory of your project. Many of the configuration options in Vagrant are relative to this root directory.
- Describe the kind of machine and resources you need to run your project, as well as what software to install and how you want to access it.
- Up and Running
- Vagrant up && vagrant ssh
- We are inside the VM now. Next, we will install the components needed for MEAN stack development.
- Git
- sudo apt-get install git
- git --version
- Node.js
- sudo apt-get update
- sudo apt-get install -y python-software-properties python g++ make
- sudo add-apt-repository ppa:chris-lea/node.js
- sudo apt-get update
- sudo apt-get install nodejs
- node -v
- npm -v
- MongoDB
- sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
- echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
- sudo apt-get update
- sudo apt-get install -y mongodb-org
- mongo --version
- Install Node.js tools
- sudo npm install -g bower grunt-cli yo generator-meanjs
- Issues on vagrant up
- Solution : This issue get solved by executing above steps sequentially.
- Fixing Error "Failed to load VMMR0.r0 (VERR_SUPLIB_WORLD_WRITABLE)" in Virtualbox
- Solution : chmod o-w /usr/lib
- References
Hi Santosh , I am facing the similar error but on Mac OSX yosemite. Tried uninstalling and reinstalling but to no help. Can you please suggest something?
ReplyDeleteThis is the error I am getting:
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["startvm", "51266d9c-9c5a-402f-9cf7-dcf3a159b791", "--type", "headless"]
Stderr: VBoxManage: error: The virtual machine 'vagrant_default_1494573999092_37112' has terminated unexpectedly during startup with exit code 1 (0x1)
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component MachineWrap, interface IMachine