Here I’m going to demonstrate how to utilize the power of VirtualBox among with Infrastructure Automation Tool like Chef to develop your next Magento powered project in a production ready environment without bloating your personal PC with extra services which you might never need otherwise.
Basically we’re going to mount working tree directory of our web store into VirtualBox instance build with chef-solo and corresponding cookbook.
We’re going to go with a very simple project setup, i.e. just download latest Magento.
tar zxf magento-22.214.171.124.tar.gz
The above instruction are specific to Linux and OSX, but you can easily find alternatives for others OS’es as well.
Unfortunately the steps we accomplished in previous section aren’t just enough to run any functional magento store yet, we’re missing a bunch of thing such as webserver, php interpreter with certain extensions, MySQL database and also probably certain configuration steps specific to the system you prefer to develop on must be accomplished.
In order to get up and running you’ve to follow instruction such as Magento Installation Guide or jump to the next section ;)
Introducing magento cookbook
And here we will take most out of it, we’ll use cookbook to bootstrap Magento stack on local PC for development purposes.
The easiest way to manage cookbooks with in our project is Berkshelf, see the next section.
Berkshelf - Manage a Cookbook or an Application’s Cookbook dependencies
Please note, some of the following commands needs be executed with in the project
directory, i.e. the
magento directory we’ve extracted in the first section.
gem install berkshelf
Install vagrant with bershelf plugin
For installing vagrant, please follow instruction available on its website: Vagrant Installation Guide
And then install plugin to make it work with berkshefl:
vagrant plugin install vagrant-berkshelf
Initialize Berkshelf to use within your project
Declare cookbook dependencies
echo "cookbook 'magento'" >> Berksfile
Pickup cookbook dependencies
Finally, bootstrap VirtualBox instance with working tree mounted
We will be mounting working tree to the corresponding directory on the VirtualBox instance, so, it can be served by the web-server.
Please note, the Vagrantfile format might differ depend on the Vagrant version, the example below was tested with Vagrant 1.3.5 and might not work with others versions!
So, let’s update
Vagrantfile with the following content:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
And then run the following command:
Finally, you can open the browser at http://126.96.36.199 to proceed with normal magento installation.
At this point you’ve virtual instance that fits all magento requirements and can be easily turned on/off with simple commands as needed. See Vagrant website for the further details.
Don’t forget to update Hacking section in your project
README file, so, every
new developer will be able to get up and running in no time. Or you can go even
further, unless you’re running production store on the PaaS, there is a good
chance you can reuse the same setup to bootstrap and maintain your production