dsadsa123111 2014-12-11 17:20
浏览 54
已采纳

如何让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.

  • 写回答

1条回答 默认 最新

  • duanji7182 2014-12-14 21:15
    关注

    It is not answer currently, but I need paste some codes for asking further question..

    The problem is on this part:

    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
    

    The error is :

    Checksum on resource (378de1) does not match checksum on content (8d39f2)
    

    the gz file is downloaded from http://us1.php.net/get/php-5.5.19.tar.gz/from/this/mirror and save to /var/chef/cache/php-5.5.19.tar.gz

    Could you manually download again, and check with below command to confirm if they are same (md5 or md5sum, depend your system)

    md5 /var/chef/cache/php-5.5.19.tar.gz
    
    or 
    
    md5sum /var/chef/cache/php-5.5.19.tar.gz
    

    Here is the md5 result from the gz file I download from internet. They should be same.

    $ md5 php-5.5.19.tar.gz
    MD5 (php-5.5.19.tar.gz) = 8ef89261aa6bb2d74df8d147f0d183a1
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料