Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modifying php.ini setting with chef php cookbook

I have installed the PHP Cookbook from opscode and the chef-dotdeb cookbook found at chef-dotdeb so that I can run PHP 5.4 in the vagrant box.

I would like to modify some of the default php.ini settings.

According to the documentation for the chef php cookbook I can modify the settings using

node['php']['directives'] = {}

for example:

node['php']['directives'] = { :short_open_tag => 'Off' }

I have made the modification in the webserver.rb script I have created in my applications cookbook. When I provision or reload the vagrant box the php.ini settings remain unchanged.

Any ideas what is wrong?

The contents of the webserver.rb file are:

include_recipe "nginx"

include_recipe "php"

node.default["php"]["directives"] = { :short_open_tag => 'Off' }

Even when i remove the dotdeb cookbook so that the only php stuff comes from the official opscode php cookbook it still doesnt update any ini values.

ADDITIONAL INFO

I have looked at the code in the opscode php cookbook that actually injects the directives into it erb php.ini template: https://github.com/opscode-cookbooks/php/blob/master/templates/ubuntu/php.ini.erb

The code that injects the appends the directives to the end of the file is:

<% @directives.sort_by { |key, val| key }.each do |directive, value| -%>
<%= "#{directive}=\"#{value}\"" %>
<% end -%>

this is always empty {}

However.... if i modify it to...

<% node.default[:php][:directives].sort_by { |key, val| key }.each do |directive, value| -%>
<%= "#{directive}=\"#{value}\"" %>
<% end -%>

Then the directives ARE injected into the template. Im not a ruby expert. What is the fundamental difference between these 2 pieces of logic???

like image 737
BNK Avatar asked Dec 16 '13 14:12

BNK


1 Answers

Might be a real long shot but I was trying to use this feature and was finding it doesn't work, then I actually found it's because I was looking at the apache2 php.ini when the cookbook by default only adds the setting to the cli php.ini file. This probably isn't an issue for Fedora/Redhat, but it is for Ubuntu because it separates the configs out under /etc/php5/ into different folders.

like image 149
Peter Fox Avatar answered Oct 20 '22 20:10

Peter Fox