Appendix A. Deployment Setup with Vagrant

As it's pretty important that you should be able to develop the application locally, let's use the Vagrant project for setting up the local deploy target.

To be brutally short, Vagrant (see http://www.vagrantup.com/) is a toolset to manage virtual machines from the command line. The end result of your setup would be this:

  1. You boot your own workstation.
  2. You go to the root of the code base.
  3. You issue vagrant up in the command line.
  4. You wait and then open the http://localhost:8888/ URL in your browser.
  5. Your web application responds to you from there.
  6. You issue vagrant halt in the command line.
  7. Your web application is not accessible now and does not waste any resources anymore.

All dependencies for your application, including the web server and database, are inside the virtual machine image managed implicitly by the Vagrant toolset. Nothing leaks to your host system.

Vagrant supports several virtual machine vendors, and we should have no trouble if we decide to use the VirtualBox project (see https://www.virtualbox.org/) as both technologies are open source and free to use.

Planning

As we'll configure the virtual machine, we need to plan our LAMP stack in detail right from the start.

We need to set up four things:

  1. PHP 5.4.
  2. Apache 2.4 (it's modern standard anyway).
  3. MySQL 5.5 (we need a database because of our application domain, which is data management).
  4. A website configured to be accessible from inside the virtual machine.

More than that, we'll need a setup script that will automate the necessary preparations of the base system, including installing all the things mentioned for setup.

Deployment will be greatly simplified by Vagrant, because it just makes the directory holding the code base (where you call vagrant up, specifically) shared inside the virtual machine as the directory named /vagrant. That slash is important as it's the vagrant folder at the root of the directory tree. As a result, the code base will always be synchronized between the deploy target and the development workstation, so you can use whatever toolchain you use to write and maintain the code base, and it will transparently and constantly be sent to the deployment target.

Vagrant hides the management of the virtual machine behind the concept of box. The box is a specially prepared virtual machine image in any format recognizable by Vagrant. These boxes have to be downloadable from somewhere, and a website located at http://www.vagrantbox.es/ holds references to a lot of such prepared images for Vagrant.

However, Vagrant recognizes, and is able to, install some boxes right out of the box. One of them is called precise64, which is Ubuntu 12.04. For simplicity, we'll use this box as it requires essentially no additional setup outside the box.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.253.223