(8) Provisioning:html
一般状况下Box只作最基本的设置,而不是一次到位的设置好全部的环境。Vagrant一般使用chef或者Puppet来作进一步的环境搭建。apache
回到刚才建立的index.html,咱们须要安装Apache。咱们下面用Puppet来完成这一设置。浏览器
1. 在项目的根目录下建立文件夹manifests,而后在该文件家中建立Puppet的配置文件default.pp,该文件内容以下: ui
# Basic Puppet Apache manifestclass apache { exec { 'apt-get update': command => '/usr/bin/apt-get update' } package { "apache2": ensure => present, } service { "apache2": ensure => running, require => Package["apache2"], }}include apache
Vagrant::Config.rundo|config| config.vm.box="base" # Enable the Puppet provisioner config.vm.provision:puppetend
(9) 运行Projectspa
为了使puppet的配置生效,若是不重启虚机,则须要执行vagrant reload命令。vagrant
$ vagrant reload
(10) 进行端口映射code
修改Vagrantfile, 添加本地端口和虚机端口的映射关系, 而后执行vagrant reload, 而后你就能够经过本地浏览器来访问:http://localhost:4567. htm
Vagrant::Config.run do |config| # Forward guest port 80 to host port 4567 config.vm.forward_port 80, 4567 end