Windows 7 让一个LAMP堆栈在一个流浪的VM上运行(在Windows7主机下),完整的说明?

Windows 7 让一个LAMP堆栈在一个流浪的VM上运行(在Windows7主机下),完整的说明?,windows-7,virtual-machine,lamp,vagrant,knife,Windows 7,Virtual Machine,Lamp,Vagrant,Knife,我有一个流浪汉VM标准问题lucid32.box正在运行。在这上面设置指示灯的完整说明是什么 我看过刀(厨师的一部分)并尝试: vagrant@lucid32:~$ knife cookbook site install apache2 但是得到 WARNING: No knife configuration file found 如何设置刀配置文件,其中应包含哪些内容 我已经在网上搜索了很多答案,但我被一些没有解释其出发点/先决条件的部分解决方案弄得不知所措 更新 我的目标是自己回答这个问

我有一个流浪汉VM标准问题lucid32.box正在运行。在这上面设置指示灯的完整说明是什么

我看过刀(厨师的一部分)并尝试:

vagrant@lucid32:~$ knife cookbook site install apache2
但是得到

WARNING: No knife configuration file found
如何设置刀配置文件,其中应包含哪些内容

我已经在网上搜索了很多答案,但我被一些没有解释其出发点/先决条件的部分解决方案弄得不知所措

更新

我的目标是自己回答这个问题,因为似乎没有人愿意这样做。以下是我目前的理解——我的目标是在稍后用红色表示我的未知/问题


在虚拟机中,您需要运行:

$knife configure
接受所有默认值

运行此操作后,在~/.chef/knife.rb中将有一个配置文件

至于你的图表: vagrant文件夹包含该项目的vagrant文件。实际的.ovf和.vmdk文件以及另一个vagran文件存在于/%USERPROFILE%/.vagrant.d中/

Vagranfile是Vagrant的配置文件,存在于多个位置,具有设置的优先顺序。项目文件夹中的文件优先:

一切都可以来自localhost,包括使用多个vm设置更复杂的Vagrant项目


编辑:为了明确“刀子配置”cmd应该在VM中运行,并删除虚假的Windows路径引用。

好的,我决定作为原始问题海报为自己完整回答这个问题。(感谢所有在此之前作出贡献的人。)

使用Vagrant和Oracle VirtualBox在Windows 64位主机上端到端设置LAMP VM

我最初问这个问题是因为尽管网上有很多说明和指南,但它们似乎没有做到:

  • 明确定义起点和先决条件
  • 为像我这样的公司环境提供指导,这些公司环境中有一台能够承载VM的Windows计算机。相反,他们假设一台基于Linux的主机
  • 清楚要设置的文件的位置:在主机上?在来宾操作系统上?(这尤其难以确定主机操作系统和来宾操作系统都是基于Linux还是基于Unix的-显示的命令行代码片段没有给出明显的线索,因为它们看起来都一样。)
  • 说明使用了哪种版本的流浪汉。有两(2)个主要版本:API版本1,它是v1.1.0之前(但不包括)的所有版本。另一个是API版本2,它是从v1.1.0开始发布的。因此,版本控制约定类似于Java。这个API版本很重要,因为,例如,v1 API脚本在Vagrant软件的API v2上根本不起作用,除非在脚本开头添加一个子句来说明要使用哪个版本

    就我个人而言,我认为流浪版本控制约定可能更简单注意:本指南适用于流浪汉1。有人告诉我,版本1拥有广泛的安装基础,而Vagrant 2仍在2013年年中的草案中。因此,我喜欢将版本1-v1LTS称为长期支持,比如Ubuntu,以表明这将持续很长一段时间

下面是一张图片,用于说明哪个API位于哪个版本的Vagrant软件上:

对于我在这里使用Vagrant的示例设置,我建议使用pre-V1.1.0(即vagrantup.com上下载的VagrantAPI 1)但是,您应该能够使用上述Vagrant软件的Vagrant 2 API版本,但您需要在脚本开头添加一个“指令”,告诉Vagrant它们适用于Vagrant 1,否则脚本将失败并显示错误消息TODO:我将尝试获取该指令,并将其放在此处以提供帮助

(Mitchell Hashimoto,流浪者创作者-请注意以上内容,以备将来出版的O'Reilly书籍:《流浪者:启动并运行:》之用)

此答案中的说明应该做什么:

在Windows 7 64位机器(或Mac或Linux机器,但主要在Windows上测试,但在Mac上应该可以正常工作,此解决方案是独立于平台的)上使用Oracle VirtualBox,为您提供一个32位Ubuntu Linux操作系统,该操作系统带有LAMP(Linux操作系统、Apache web服务器、MySQL数据库、PHP)堆栈,作为虚拟机运行。我已经测试过PHP OK(通过标准phpinfo.PHP文件,看到MySQL正在运行,但还没有测试)

设置在漫游虚拟机上运行的灯组的其他方法

注意:对于那些(像我一样)希望使用Drupal开源内容管理框架的LAMP堆栈的人来说,另一个非常现成的解决方案是: 您应该能够只遵循下面我的先决条件,然后从上面的URL下载.zip,并按照上面的说明从命令行运行
vagrant up
,以启动VM并等待它的构建和启动(其中一些是第一次一次性的,因为一旦你设置了映像,后续的引导应该会更快)。你可以“免费”获得很多其他开发人员的东西(也就是说,为了省去你安装它们的工作量),比如git、drush(我想)和性能评测工具。然后转到[服务器地址]/install.php来安装Drupal。这似乎工作得很好,没有问题-我已经尝试过了,但没有进行广泛的测试。如果收到错误消息,您可能需要禁用xhprof的安装-有关详细信息,请参阅

另一个选项是使用此配置工具: -这是一种用于配置Vagrant设置的可视点击方法。这在Vagrant 2上有效(我认为,更新是的,至少在Vagrant 1.2.2上有效)。更新:事实上,我已经成功地实现了这一点,并基于在本地运行Drupal的设置-请参阅我的指南:

更新

这里有一些其他的t
vagrant@lucid32:~$ sudo passwd -u root
passwd: password expiry information changed.
vagrant@lucid32:~$ sudo passwd root
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
vagrant@lucid32:~$ su root
Password:
root@lucid32:/home/vagrant#
mkdir lamp-project
cd lamp-project
mkdir configs
cd ..
cd lamp-project
mkdir manifests
C:\Users\rdavis\lamp-project>vagrant box add lucid32 http://files.vagrantup.com/lucid32.box
C:\Users\rdavis\lamp-project>vagrant init lucid32
C:\Users\rdavis\lamp-project>vagrant init
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

C:\Users\rdavis\lamp-project>
config.vm.box = "lucid32"
config.vm.provision :puppet do |puppet|
    puppet.manifests_path = File.expand_path("../manifests", __FILE__)
end
config.vm.forward_port 80, 8080
config.vm.share_folder "configs", "/configs", File.expand_path("../configs", __FILE__)
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant::Config.run do |config|

config.vm.box = "lucid32"
config.vm.provision :puppet do |puppet|
    puppet.manifests_path = File.expand_path("../manifests", __FILE__)
end
config.vm.forward_port 80, 8080
config.vm.share_folder "configs", "/configs", File.expand_path("../configs", __FILE__)

 # All Vagrant configuration is done here. The most common configuration
 # options are documented and commented below. For a complete reference,
 # please see the online documentation at vagrantup.com.

 # Every Vagrant virtual environment requires a box to build off of.
 # config.vm.box = "lucid32" 
 # (this is already done above, but if you have a box called 'base' which is an Ubuntu lucid32 then you can use: config.vm.box = "base". This info may be helpful if you get error: "The box 'base' could not be found.")

 # The url from where the 'config.vm.box' box will be fetched if it
 # doesn't already exist on the user's system.
 # config.vm.box_url = "http://example.com/path/to/above.box"

 # Boot with a GUI so you can see the screen. (Default is headless)
 # config.vm.boot_mode = :gui

 # Assign this VM to a host-only network IP, allowing you to access it
 # via the IP. Host-only networks can talk to the host machine as well as
 # any other machines on the same network, but cannot be accessed (through this
 # network interface) by any external networks.
 # config.vm.network :hostonly, "192.168.33.10"

 # Assign this VM to a bridged network, allowing you to connect directly to a
 # network using the host's network device. This makes the VM appear as another
 # physical device on your network.
 # config.vm.network :bridged

 # Forward a port from the guest to the host, which allows for outside
 # computers to access the VM, whereas host only networking does not.
 # config.vm.forward_port 80, 8080

 # Share an additional folder to the guest VM. The first argument is
 # an identifier, the second is the path on the guest to mount the
 # folder, and the third is the path on the host to the actual folder.
 # config.vm.share_folder "v-data", "/vagrant_data", "../data"

 # Enable provisioning with Puppet stand alone.  Puppet manifests
 # are contained in a directory path relative to this Vagrantfile.
 # You will need to create the manifests directory and a manifest in
 # the file base.pp in the manifests_path directory.
 #
 # An example Puppet manifest to provision the message of the day:
 #
 # # group { "puppet":
 # #   ensure => "present",
 # # }
 # #
 # # File { owner => 0, group => 0, mode => 0644 }
 # #
 # # file { '/etc/motd':
 # #   content => "Welcome to your Vagrant-built virtual machine!
 # #               Managed by Puppet.\n"
 # # }
 #
 # config.vm.provision :puppet do |puppet|
 #   puppet.manifests_path = "manifests"
 #   puppet.manifest_file  = "base.pp"
 # end

 # Enable provisioning with chef solo, specifying a cookbooks path, roles
 # path, and data_bags path (all relative to this Vagrantfile), and adding
 # some recipes and/or roles.
 #
 # config.vm.provision :chef_solo do |chef|
 #   chef.cookbooks_path = "../my-recipes/cookbooks"
 #   chef.roles_path = "../my-recipes/roles"
 #   chef.data_bags_path = "../my-recipes/data_bags"
 #   chef.add_recipe "mysql"
 #   chef.add_role "web"
 #
 #   # You may also specify custom JSON attributes:
 #   chef.json = { :mysql_password => "foo" }
 # end

 # Enable provisioning with chef server, specifying the chef server URL,
 # and the path to the validation key (relative to this Vagrantfile).
 #
 # The Opscode Platform uses HTTPS. Substitute your organization for
 # ORGNAME in the URL and validation key.
 #
 # If you have your own Chef Server, use the appropriate URL, which may be
 # HTTP instead of HTTPS depending on your configuration. Also change the
 # validation key to validation.pem.
 #
 # config.vm.provision :chef_client do |chef|
 #   chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
 #   chef.validation_key_path = "ORGNAME-validator.pem"
 # end
 #
 # If you're using the Opscode platform, your validator client is
 # ORGNAME-validator, replacing ORGNAME with your organization name.
 #
 # IF you have your own Chef Server, the default validation client name is
 # chef-validator, unless you changed the configuration.
 #
 #   chef.validation_client_name = "ORGNAME-validator"
end
$config_path = "/configs"
$vagrant_base_path = "/vagrant"
Exec { path => "/bin:/usr/bin:/usr/local/bin" }
group { "puppet": ensure => present }
exec { "apt-get update": command => "apt-get update" }
class apache {

    exec { "enable-mod_rewrite":
        require => Package["apache2"],
        before => Service["apache2"],
        command => "/usr/sbin/a2enmod rewrite"
    }
    package { "apache2":
        ensure => present
    }

    service { "apache2":
        ensure => running,
        require => Package["apache2"]
    }
}
class php {
    package { "libapache2-mod-php5": ensure => present }
    package { "php5": ensure => present }
    package { "php5-cli": ensure => present }
    package { "php5-dev": ensure => present }
    package { "php5-mysql": ensure => present }
    package { "php-pear": ensure => present }
    exec { "pear upgrade":
        command => "/usr/bin/pear upgrade",
require => Package["php-pear"],
    }
}
class mysql {
  package { "mysql-server":
    require => Exec["apt-get update"],
    ensure => present,
  }
  service { "mysql":
    enable => true,
    ensure => running,
    require => Package["mysql-server"],
  }
  exec { "Set MySQL server root password":
        require => Package["mysql-server"],
        unless => "/usr/bin/mysqladmin -uroot -proot status",
        command => "/usr/bin/mysqladmin -uroot password root",
  }
}
include apache
include php
include mysql
C:\Users\rdavis\lamp-project>vagrant up
There is a syntax error in the following Vagrantfile. The syntax error
message is reproduced below for convenience:

C:/Users/rdavis/lamp-project/Vagrantfile:6: invalid multibyte char (US-ASCII)
C:/Users/rdavis/lamp-project/Vagrantfile:6: syntax error, unexpected $end
Could not parse for environment production: Could not match ?/configs? at /tmp/vagrant-puppet/manifests/default.pp:1 on node lucid32.hsd1.ca.comcast.net.

The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
There was an error executing the following command with VBoxManage:

["list", "hostonlyifs"]
←[1;35merr: /Stage[main]/Apache/File[/etc/apache2/sites-enabled/000-default]: Could not evaluate: Could not retrieve information from environment production source(s) file:/configs/000-default at /tmp
/vagrant-puppet/manifests/default.pp:11←[0m
vagrant@lucid32:/etc/php5/cli$ a2enmod php5
Module php5 already enabled
vagrant@lucid32:/etc/php5/cli$ sudo apache2ctl restart
[default] The guest additions on this VM do not match the install version of
VirtualBox! This may cause things such as forwarded ports, shared
folders, and more to not work properly. If any of those things fail on
this machine, please update the guest additions and repackage the
box.

Guest Additions Version: 4.2.0
VirtualBox Version: 4.2.4