sexta-feira, 10 de fevereiro de 2012

Instalação do Vagrant


Precisa de um ambiente que simule o servidor onde fará o deploy do projeto? Cansado de lidar com as diferenças entre sistemas operacionais, versões etc?

Esta semana tive a oportunidade de conhecer o Vagrant. Um sistema que trabalha com a API do Virtual Box. Nele é possivel de uma maneira fácil criar uma máquina virtual com as caracteristicas que precisar para simular o ambiente online.

O tutorial abaixo mostra um resumo do que li a respeito para  criar uma VM com Ubuntu, python2.6, virtualenv, etc.

  1. Baixe e instale a Oracle VM Virtual Box (https://www.virtualbox.org/wiki/Downloads
  2. Baixe e instale o Ruby (http://rubyinstaller.org/downloads/
  3. Baixe o Development Kit (http://rubyinstaller.org/downloads/
    1. Installation Instructions (https://github.com/oneclick/rubyinstaller/wiki/Development-Kit
      1. While installation is (in general) simple, please ensure you carefully follow each step below. 
      2. Preparation 
      3. If you previously installed the legacy DevKit devkit-3.4.5r3-20091110.7z, its artifacts were extracted into each Ruby installation and need to be manually removed. Remove the gcc.bat, make.bat, and sh.bat stub batch files in <RUBY_INSTALL_DIR>\bin and the <RUBY_INSTALL_DIR>\devkit subdirectory for each Ruby installation using the legacy DevKit. 
      4. If you previously installed one of the legacy self-extracting DevKit’s, follow the SFX DevKit upgrade instructions. 
    2. Download Files 
      1. The current DevKit is available at the RubyInstaller download page with older versions available at the archives page. As backup, check our GitHub downloads page. 
    3. Extract Files 
      1. Left double-click the self-extracting executable (SFX) downloaded from Step 2 and choose a directory (without spaces) to install the DevKit artifacts into. For example, C:\DevKit. NOTE: the SFX is really a 7-Zip archive with a bit of embedded magic. If you already have 7-Zip installed, you can simply right-click it and extract it’s contents as you would a normal 7z archive. In the instructions that follow, the directory that you selected is identified as <DEVKIT_INSTALL_DIR>. 
    4. Run Installation Scripts 
      1. cd <DEVKIT_INSTALL_DIR> from Step 3 above. 
      2. ruby dk.rb init to generate the config.yml file to be used later in this Step. Your installed Rubies will be listed there (only those installed by a RubyInstaller package are detected at present). 
      3. edit the generated config.yml file to include installed Rubies not automagically discovered or remove Rubies you do not want to use the DevKit with. 
      4. [optional] ruby dk.rb review to review the list of Rubies to be enhanced to use the DevKit and verify the changes you made to it are correct. 
      5. finally, ruby dk.rb install to DevKit enhance your installed Rubies. This step installs (or updates) an operating_system.rb file into the relevant directory needed to implement a RubyGems pre_install hook and a devkit.rb helper library file into <RUBY_INSTALL_DIR>\lib\ruby\site_ruby. NOTE: you may need to use the --force option to update (with backup of the originals) the above mentioned files as discussed at the SFX DevKit upgrade FAQ entry. 
    5. Test Installation 
  4. Confirm your Ruby environment is correctly using the DevKit by running gem install rdiscount --platform=ruby. RDiscount should install correctly and you should see Temporarily enhancing PATH to include DevKit... in the screen messages. Next run ruby -rubygems -e "require 'rdiscount'; puts RDiscount.new('**Hello RubyInstaller**').to_html" to confirm that the rdiscount gem is working. 
  5. Adicione o caminho da pasta bin do ruby da instalção feita no Path. Ex. C:\Ruby193\bin 
  6. Execute o comando: gem install vagrant 
  7. Antes de criar sua maquina, crie uma pasta para abrigar os arquivos de configuraçao: 
    1. mkdir vagrant-machine 
    2. cd vagrant-machine 
    3. vagrant box add lucid32 http://files.vagrantup.com/lucid32.box
    4. vagrant init lucid32 
    5. vagrant up 
    6. Acesse via ssh a maquina virtual: 
    7. pelo putty, conecte em vagrant@127.0.0.1, com a senha vagrant 
  8. Instale os pacotes de desenvolvimento: 
    1. sudo apt-get install python2.6 python2.6-dev libxml2-dev libxslt1-dev python-libxml2 python-setuptools git-core build-essential libxml2-dev libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev libgeoip-dev memcached libmemcached-dev python-mysqldb libmysqlclient16-dev python-virtualenv 
  9. Vá até a home do usuário e rode o comando abaixo para atualizar o apt-get e outros pacotes: 
    1. sudo sh postinstall.sh
    2. Vá no VagrantFile no diretorio que instalou o passo 6.a e edite. 
    3. Descomente a linha: # config.vm.forward_port 80, 8080 e configure para as portas que deseja utilizar no windows quando rodar os projetos. Ex: 
      1. config.vm.forward_port 8000, 8000 
      2. # config.vm.forward_port 9000, 9000
hasta!

0 comentários:

Postar um comentário

 
Melhor visualizado em 1024x768