I'm new on Chef. I tried writing a recipe that installs Zend OpCache (for PHP 5.4, since its not built-in yet) using Chef PHP cookbook.
I tried using the php_pear
php_pear "opcache" do
package_name "ZendOpcache"
action :install
preferred_state "beta"
zend_extensions ["opcache.so"]
directives node['php']['opcache']['directives']
end
but the .ini
file generated has ZendOpcache
as the prefix for the variables
ubuntu@webserver3:~$ cat /etc/php5/conf.d/ZendOpcache.ini
; configuration for php ZendOpcache module
zend_extension=/usr/lib/php5/20100525/opcache.so
ZendOpcache.revalidate_freq="60"
ZendOpcache.enable_cli="1"
ZendOpcache.memory_consumption="128"
ZendOpcache.interned_strings_buffer="8"
ZendOpcache.fast_shutdown="1"
ZendOpcache.max_accelerated_files="4000"
ZendOpcache.save_comments="0"
the prefix should be opcache
.
I then tried manually create the .ini
file myself
template "#{node['php']['ext_conf_dir']}/opcache.ini" do
source "extension.ini.erb"
cookbook "php"
owner "root"
group "root"
mode "0644"
variables(:name => 'opcache', :extensions => {'/usr/lib/php5/20100525/opcache.so' => true}, :directives => node['php']['opcache']['directives'])
action :create
end
When I tried executing PHP there is this warning
PHP Warning: Module 'Zend OPcache' already loaded in Unknown on line 0
[exec] PHP Warning: Zend OPcache: module registration failed! in Unknown on line 0
The opcache module loading is done in two places, ZendOpcache.ini
and the manual opcache.ini
.
The only solution I can come up with and working is this
php_pear "opcache" do
package_name "ZendOpcache"
action :install
preferred_state "beta"
zend_extensions ["opcache.so"]
end
template "#{node['php']['ext_conf_dir']}/opcache.ini" do
source "extension.ini.erb"
cookbook "php"
owner "root"
group "root"
mode "0644"
variables(:name => 'opcache', :extensions => {}, :directives => node['php']['opcache']['directives'])
action :create
end
this will create two files ZendOpcache.ini
and opcache.ini
. One for loading the module, and the other for putting configuration.
It seems a bit waste using two config file for one module. Is there any simpler way to do this?