Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vagrant and Chef: How to install a newer version of PHP?

I'm relatively new to using Vagrant and Chef. I'm currently running Ubuntu Lucid 64 and using the Opscode PHP cookbook which installs PHP 5.3.2, as a package, by default. I'd like to install PHP 5.3.8 or 9 (either from source or as a package) but I can't seem to figure out how to configure it correctly. I have copied over the dependent cookbooks (build-essential, xml, mysql). This is what I have so far:

# vagrant_main/recipes/default.rb

require_recipe "apt"

node.override["php"]["version"] = "5.3.9"
require_recipe "php::source"

But I am getting an error. Here are the relevant lines of the stack trace:

NameError: wrong constant name DebianBeforeSqueeze?
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/mixin/recipe_definition_dsl_core.rb:56:in `const_defined?'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/mixin/recipe_definition_dsl_core.rb:56:in `method_missing'
/tmp/vagrant-chef-1/chef-solo-1/mysql/recipes/client.rb:26:in `from_file'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/cookbook_version.rb:578:in `load_recipe'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/mixin/language_include_recipe.rb:40:in `include_recipe'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/mixin/language_include_recipe.rb:27:in `each'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/mixin/language_include_recipe.rb:27:in `include_recipe'
/tmp/vagrant-chef-1/chef-solo-1/php/recipes/source.rb:25:in `from_file'

Update: If I tell the PHP recipe not to worry about MySQL, it seems to install fine...

node.override["php"]["version"] = "5.3.9"
node.override["php"]["configure_options"]["mysql"] = false
require_recipe "php::source"

...however, Apache doesn't seem to know which version of PHP it's running. php_info() is reporting that it's using PHP 5.3.2, but command line (php -v) is correctly reporting 5.3.9.

What am I doing wrong?

like image 925
Andrew Avatar asked Jan 17 '12 23:01

Andrew


1 Answers

In /etc/apache2/mods-enabled/php5.load you can detemine which version of php will Apache use (it has to be installed).

like image 72
Matěj Koubík Avatar answered Oct 01 '22 19:10

Matěj Koubík