How to create a virtual host with vagrant and chef

☆樱花仙子☆ 提交于 2019-12-04 11:22:49
scriptin

Invocation of web_app must go into a recipe.

For example, you can create my-site cookbook in a directory which is also named my-site. There must be at least 3 files:

  1. my-site/metadata.rb with basic metadata:

    name "my-site"
    description "Adds Apache domain configuration for my site"
    
  2. my-site/recipes/default.rb:

    include_recipe "apache2"
    
    web_app "my_site" do
      server_name "my-site.localhost"
      server_aliases ["www.my-site.localhost"]
      docroot "/vagrant"
    end
    
  3. my-site/templates/default/web_app.conf.erb - copy it's contents from example template from apache2 cookbook (apache2/templates/default/web_app.conf.erb).

Note that I use "my-site.localhost" as ServerName. You should replace it with your domain name, because node['fqdn'] and node['domain'] are not defined in your code. DocRoot must be also correct path to your site - it probably will be your vagrant synced directory, which is "/vagrant" by default (you can change it).

You'll porbably also want to add 192.168.33.10 my-site.localhost to your hosts file on the host machine (your actual OS).

I've written an introductory post on Vagrant and Chef solo, it may be useful to you: http://scriptin.github.io/2013-05-09/vagrant-chef-intro.html

It has to go into a recipe of a cookbook that you have to write since it's (apparently? I don't know the Apache cookbook so good) not possible to configure Apache virtual hosts through plain node configuration (chef.json).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!