sous-chefs/php

Installing APCu with configuration directives

Closed this issue · 3 comments

Cookbook version

2.1.1

Chef-client version

12.16.42

Platform Details

Ubuntu 14.04 on DigitalOcean

Scenario:

Installing php_pear[apcu] with configuration directives.

Steps to Reproduce:

php_pear "apcu" do
  version "4.0.11"
  directives(
    shm_size: 128,
    shm_segments: 1,
    enable_cli: 1,
    stat: 0,
    cache_by_default: 1,
    mmap_file_mask: "/tmp/apc.XXXXXX",
    max_file_size: "10M",
    ttl: 7200,
    user_ttl: 7200,
  )
  action :install
end

Expected Result:

Generated config file /etc/php5/mods-available/apcu.ini should contain correct directives, apc.*

# /etc/php5/mods-available/apcu.ini
apc.shm_size=128
apc.shm_segments=1
apc.enable_cli=1
...

Actual Result:

# /etc/php5/mods-available/apcu.ini
apcu.shm_size=128
apcu.shm_segments=1
apcu.enable_cli=1
...

APCu directives are apc.*, not apcu.* so PHP doesn't recognize these config params.
Don't see a way to do that with current cookbook.

For anyone having the same problems, I've found a fix.
It will probably only work with package install on Ubuntu, don't know about others.

apt_package "php5-apcu" do
  action :install
end

template "#{node['php']['ext_conf_dir']}/apcu.ini" do
  source 'extension.ini.erb'
  cookbook 'php'
  owner 'root'
  group 'root'
  mode '0644'
  variables(
    name: "apc",
    extensions: { "apcu.so" => false },
    directives: {
      shm_size: "128M",
      shm_segments: 1,
      enable_cli: 1,
      stat: 0,
      cache_by_default: 1,
      mmap_file_mask: "/tmp/apc.XXXXXX",
      max_file_size: "10M",
      ttl: 7200,
      user_ttl: 7200,
    }
  )
  action :create
end

Advantage of this is that any directives change will be picked up on each Chef run,
while that doesn't seem possible with php_pear resource.

Disadvantage of course is that it only works for package installs and wouldn't work where pecl or pear install is required, so I think issue should remain open.

Closing due to inactivity.

If this is still an issue please reopen or open another issue. Alternatively drop by the #sous-chefs channel on the Chef Community Slack and we'll be happy to help!

Thanks,
Sous-Chefs

lock commented

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.