In a previous post I wrote about how to create new local environments very easy, and for that example I was using a LAMP environment, however sometimes you have to work with Java, so, for those cases you can use the same tools: Vagrant, Virtualbox, Puppet or Chef.
If you are not yet using DevEnv, create your project and download it.
$ mkdir project_one $ cd project_one $ git clone https://github.com/bbh/devenv.git $ cd devenv $ git submodule init $ git submodule update $ cd ../
Create your Vagrantfile
$ vi Vagrantfile
Use this configuration for your Vagrantfile (change the IP address if you need to)
Vagrant::Config.run do |config| config.vm.define :tomcat do |tom| tom.vm.box = "centos64" tom.vm.box_url = "http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130731.box" tom.vm.network :hostonly, "192.168.30.10" tom.vm.provision :chef_solo do |chef| chef.cookbooks_path = "devenv/chef/cookbooks" chef.run_list = [ "recipe[tomcat::default]" ] end end end
Start your vagrant
$ vagrant up tomcat
And that’s it, now you can access your new Tomcat server using
$ vagrant ssh tomcat
And access it via web using http://192.168.30.10:8080/ (or the IP address previously chosen)
Now you have a functional Tomcat to deploy your projects without affecting your local environment. Enjoy!