title: How to create a virtual host with vagrant and chef
body: <p>I've setup my first vagrant machine, with some cookbooks downloaded through knife.</p>
  
  <p>I am stuck with the setup of a virtual host.</p>
  
  <p>Here's my Vagrantfile:</p>
  
  <pre><code>Vagrant.configure("2") do |config|
  
    config.vm.box = "precise32"
  
    config.vm.box_url = "http://files.vagrantup.com/precise32.box"
  
    config.vm.network :forwarded_port, guest: 80, host: 8080
  
    config.vm.network :private_network, ip: "192.168.33.10"
  
  
    config.vm.provision :chef_solo do |chef|
      chef.json = {
          "mysql" =&gt; {
          "server_root_password" =&gt; "admin",
          "server_repl_password" =&gt; "admin",
          "server_debian_password" =&gt; "admin"
          },
          "apache" =&gt; {
              "listen_address" =&gt; "0.0.0.0"
          }
      }
      chef.add_recipe "apt"
      chef.add_recipe "vim"
      chef.add_recipe "openssl"
      chef.add_recipe "apache2"
      chef.add_recipe "mysql"
      chef.add_recipe "mysql::server"
      chef.add_recipe "php"
      # chef.add_recipe "php::module_apc"
      chef.add_recipe "php::module_curl"
      chef.add_recipe "php::module_mysql"
      chef.add_recipe "apache2::mod_php5"
      chef.add_recipe "apache2::mod_rewrite"
    end
  
    web_app "blog_site" do
      server_name "blog"
      server_aliases [ "blog.#{node['domain']}", node['fqdn'] ]
      docroot "/var/www/blog_site"
    end
  
    #
  end
  </code></pre>
  
  <p>I've seen <a href="http://community.opscode.com/cookbooks/apache2" rel="nofollow">here</a> that if I want to set a virtual host through the apache cookbook I have to use the "web_app" definition.</p>
  
  <p>I've added the <code>web_app</code> to the vagrant file but I am getting this error</p>
  
  <pre><code>in `block in &lt;top (required)&gt;': undefined method `web_app' for main:Object (NoMethodError)
  </code></pre>
  
  <p>that means (I think) that syntax is wrong :)</p>
  
  <p>How can I fix this? Where the definition "web_app" goes?</p>