08 August 2015

base box and new project

  1. choosing a base box

    1. ubuntu

       ubuntu/trusty64
       ubuntu/trusty32
       ubuntu/precise64
       ubuntu/precise32
      
    2. centos, debian, fedora, freebsd

       chef/centos-6.5
       chef/debian-7.4
       chef/fedora-20
       chef/freebsd-9.2
      
  2. init a new project

         # host
         $ cd
         $ mkdir first-box-factory
         $ ^mkdir^cd
    
         # host
         $ vagrant init -m ubuntu/trusty64
         $ vagrant up
    

installing some software

  1. software

    1. nodejs check my post 2015 05 09 getting revealjs running on your computer

    2. ruby check my post 2015 03 08 setting up my mac

    3. jekyll check my post 2015 03 04 recreate my github page

    4. lynx text-based web browser wikipedia

  2. install

         # host
         $ vagrant ssh
    
         # guest
         $ sudo apt-get update -y
         $ sudo apt-get install nodejs -y
         $ sudo apt-get install lynx-cur -y
         $ sudo apt-get install ruby1.9.1-dev -y
    
         $ sudo gem install jekyll -y
         $ jekyll --version
    

gen a box

  1. gen

         $ vagrant package --output first-box-jekyll.box
    

listing installing removing box

  1. subcommands

         # host
         $ vagrant box list
         $ vagrant box add
         $ vagrant box remove
    
  2. list boxes

         $ vagrant box list
         sparkmooc/base (virtualbox, 0)
    
         # box name      => sparkmooc/base
         # provider name => virtualbox
         # box version   => 0
    
         # host
         $ ls ~/.vagrant.d/boxes
         sparkmooc-VAGRANTSLASH-base
    
  3. add box

         # host
         $ vagrant box add [name] [address]
    
         # address forms
         # 1. vendor/name
         # 2. http://...
         # 3. file:///...
         # 3. a local filename
    
         # host
         $ vagrant box add first-box-jekyll first-box-jekyll.box
         $ vagrant box list
    
  4. remove box

         # host
         $ vagrant box remove [name]
    
         # host
         $ vagrant box remove [name] --provider [provider] --box-version [version]
    
         # host
         $ vagrant box remove first-box-jekyll
    

using the box

  1. find box

         # host
         $ vagrant box list | grep jekyll
         first-box-jekyll (virtualbox, 0)
    
  2. create a blog project

         # host
         $ cd
         $ mkdir corporate-blog
         $ ^mkdir^cd
    
         # host
         $ vagrant init -m first-box-jekyll
    
         # host
         $ vagrant up
         $ vagrant ssh
    
         # guest
         $ cd /vagrant
         # gen the first version of the corporate blog
         $ jekyll new -f .
    
         # guest
         # build the html version
         $ jekyll build
    
         # guest
         $ jekyll serve -H 0.0.0.0 --detach
         ...
         Server address: http://0.0.0.0:4000/
         Server detached with pid '2159'. Run 'kill -9 2159' to stop the server.
         ...
    
         # guest
         $ lynx 127.0.0.1:4000
    

forwarding ports

  1. edit Vagrantfile

         # host
         $ pico Vagrantfile
         Vagrant.configure(2) do |config|
             config.vm.box = "first-box-jekyll"
             config.vm.network :forwarded_port, guest: 4000, host: 8080, host_ip: "127.0.0.1"
         end
    
  2. apply the new changes

         # host
         $ vagrant reload
    
         # host
         $ vagrant ssh
    
         # guest
         $ cd /vagrant
         $ jekyll serve -H 0.0.0.0 --detach
    


blog comments powered by Disqus