0

I am using redis into my project using chef. We are creating server automation, so everything is done using chef recipe's only. I have installed php-redis using chef. Now I need to add two variables into my php.ini defining my session path.

Since we are doing every configuration using chef, I would like to know how can I add variables into php.ini using chef. Searched on web a lot and everybody recommended to use your own php.ini file instead. Which one is the best solution and any guidance on the same will be highly appreciated. I am very new to chef.

  • Environment variables aren't usually wet in `php.ini`. You'd typically do it at the server or webserver level. – ceejayoz Feb 26 '15 at 13:45

1 Answers1

1

A lot depends on how you have structured deploying php.ini in the first place.

However, assuming you are using the most current php cookbook, this has support for adding directives to the default php.ini

This is done by creating a Hash of attribute :key => value pairs as a node attribute and the underlying template will render these at the end of the file.

Here's an example of how to override the Hash with a few variables, where this might be placed inside another cookbook's attribute file that depends on the php cookbook:

override['php']['directives'] = {
  :memory_limit => '128M',
  :post_max_size => '16M',
  :upload_max_filesize => '12M'
}

This will be used in the php.ini template to render these attributes at the end of the file.

You can override attributes at a variety of layers - I recommend reading the About Attributes to get a deeper understanding on how to use attributes effectively.

Mike Fiedler
  • 2,152
  • 1
  • 17
  • 33