如何让vagrant安装php> v.5.4?

I configured a vagrantfile to install php >= v.5.4 via chef-solo. But I get some troubles. Tell me please if I am downloading some cookbook for chef provision can I modify something inside them, or I have just to configure the Vagrantfile???

This is my vagrantfile:

VAGRANTFILE_PI_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "precise32"
  config.vm.box_url = "http://files.vagrantup.com/precise32.box"
  config.vm.network "private_network", ip: "192.168.33.10", auto_config: true
  config.vm.synced_folder "./shared", "/var/www"
  config.vm.provision :shell, :inline => 'apt-get update'
  config.omnibus.chef_version = :latest
  config.vm.provision "chef_solo" do |chef|
     chef.cookbooks_path = "cookbooks"
     chef.add_recipe "apache2"
     chef.add_recipe "apache2::mod_rewrite"
     chef.add_recipe "mysql::server"
     chef.add_recipe "mysql::client"
     chef.add_recipe "php::source"

     chef.json = {
        :mysql => {
            "server_root_password" => ''
        },
        :apache => {
            "default_site_enabled" => true
        },
        :php => {
            "install_method" => "source",          
            "version" => "5.5.19",
        },
     }
  end
end

This is cookbook/php/recipes/source.rb:

configure_options = node['php']['configure_options'].join(' ')

include_recipe 'build-essential'
include_recipe 'xml'
include_recipe 'mysql::client' if configure_options =~ /mysql/
include_recipe 'yum-epel' if node['platform_family'] == 'rhel'

pkgs = value_for_platform_family(
  %w{ rhel fedora } => %w{ bzip2-devel libc-client-devel curl-devel freetype-devel gmp-devel libjpeg-devel krb5-devel libmcrypt-devel libpng-devel openssl-devel t1lib-devel mhash-devel },
  %w{ debian ubuntu } => %w{ libbz2-dev libc-client2007e-dev libcurl4-gnutls-dev libfreetype6-dev libgmp3-dev libjpeg62-dev libkrb5-dev libmcrypt-dev libpng12-dev libssl-dev libt1-dev },
  'default' => %w{ libbz2-dev libc-client2007e-dev libcurl4-gnutls-dev libfreetype6-dev libgmp3-dev libjpeg62-dev libkrb5-dev libmcrypt-dev libpng12-dev libssl-dev libt1-dev }
  )

pkgs.each do |pkg|
  package pkg do
    action :install
  end
end

version = node['php']['version']

remote_file "#{Chef::Config[:file_cache_path]}/php-#{version}.tar.gz" do
  source "#{node['php']['url']}/php-#{version}.tar.gz/from/this/mirror"
  checksum node['php']['checksum']
  mode '0644'
  not_if "which #{node['php']['bin']}"
end

if node['php']['ext_dir']
  directory node['php']['ext_dir'] do
    owner 'root'
    group 'root'
    mode '0755'
    recursive true
  end
  ext_dir_prefix = "EXTENSION_DIR=#{node['php']['ext_dir']}"
else
  ext_dir_prefix = ''
end

bash 'build php' do
  cwd Chef::Config[:file_cache_path]
  code <<-EOF
  tar -zxf php-#{version}.tar.gz
  (cd php-#{version} && #{ext_dir_prefix} ./configure #{configure_options})
  (cd php-#{version} && make && make install)
  EOF
  not_if "which #{node['php']['bin']}"
end

directory node['php']['conf_dir'] do
  owner 'root'
  group 'root'
  mode '0755'
  recursive true
end

directory node['php']['ext_conf_dir'] do
  owner 'root'
  group 'root'
  mode '0755'
  recursive true
end

include_recipe "php::ini"

But it doesn't work. This is the throwed error:

==> default: ================================================================================
==> default: Error executing action `create` on resource 'remote_file[/var/chef/cache/php-5.5.19.tar.gz]'
==> default: ================================================================================
==> default: Chef::Exceptions::ChecksumMismatch
==> default: ----------------------------------
==> default:
==> default: Checksum on resource (378de1) does not match checksum on content (8d39f2)
==> default:
==> default: Resource Declaration:
==> default: ---------------------
==> default: # In /tmp/vagrant-chef-3/chef-solo-1/cookbooks/php/recipes/source.rb
==> default:
==> default:  42: remote_file "#{Chef::Config[:file_cache_path]}/php-#{version}.tar.gz" do
==> default:  43:   source "#{node['php']['url']}/php-#{version}.tar.gz/from/this/mirror"
==> default:  44:   checksum node['php']['checksum']
==> default:  45:   mode '0644'
==> default:  46:   not_if "which #{node['php']['bin']}"
==> default:  47: end
==> default:  48:
==> default:
==> default: Compiled Resource:
==> default: ------------------
==> default: # Declared in /tmp/vagrant-chef-3/chef-solo-1/cookbooks/php/recipes/source.rb:42:in `from_file'
==> default:
==> default: remote_file("/var/chef/cache/php-5.5.19.tar.gz") do
==> default:   provider Chef::Provider::RemoteFile
==> default:   action "create"
==> default:   retries 0
==> default:   retry_delay 2
==> default:   default_guard_interpreter :default
==> default:   path "/var/chef/cache/php-5.5.19.tar.gz"
==> default:   backup 5
==> default:   atomic_update true
==> default:   source ["http://us1.php.net/get/php-5.5.19.tar.gz/from/this/mirror"]
==> default:   use_etag true
==> default:   use_last_modified true
==> default:   cookbook_name :php
==> default:   recipe_name "source"
==> default:   checksum "378de162efdaeeb725ed38d7fe956c9f0b9084ff"
==> default:   mode "0644"
==> default:   not_if "which php"
==> default: end

What can you suggest me? If I have to show more code, please tell, because I'm just the beginner with vagrant.

查看全部
dsadsa123111
dsadsa123111
2014/12/11 17:20
  • vagrant
  • php
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

1个回复