11

I am trying to install the latest version of php on a centos box and am struggling.

The cookbook i have been looking at is the opscode one: https://github.com/opscode-cookbooks/php

It doesnt look like i can install php 5.5 using that.

To install manually i would simply do the following (on centos 6.4):

rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
yum install php55w php55w-opcache

How does this translate into using chef (solo) to get php 5.5 installed?

Marty Wallace
  • 34,046
  • 53
  • 137
  • 200

2 Answers2

14

It always works by installing from source, but yum is preferred to install rpm to manage dependencies and updates.

If you just want php v5.3, go ahead using the php cookbook where the default option is installing php53 from CentOS yum repo.

If you want php v5.5, you can just provide another recipe to include a yum repository contains php55 like Webtatic EL yum repository or servergrove.com:

remote_file "#{Chef::Config[:file_cache_path]}/webtatic_repo_latest.rpm" do
    source "http://mirror.webtatic.com/yum/el6/latest.rpm"
    action :create
end

rpm_package "jmxtrans" do
    source "#{Chef::Config[:file_cache_path]}/webtatic_repo_latest.rpm"
    action :install
end

Then you just need to override the attribute node['php']['packages'] in your node/environment/role object to install php v5.5 via the opscode php cookbook:

node['php']['packages'] = ['php55w', 'php55w-devel', 'php55w-cli', 'php55w-pear']
shawnzhu
  • 7,233
  • 4
  • 35
  • 51
1

By default the php cookbook uses pre-built packages to install PHP on Enterprise Linux. You can change the install_method attribute in attributes/default.rb to source

default['php']['install_method'] = 'source'

You also need to change the default['php']['version'], default['php']['checksum'] or compile options default['php']['configure_options'] etc. to make it work.

If you want to use the pre-compiled packages, look into Chef's resources and providers, see if it is possible to install RPM packages from a URL within recipes.

Terry Wang
  • 13,840
  • 3
  • 50
  • 43