Development repository for the php cookbook
Apache License 2.0
387
111
611

This will probably require some extra channels and what not, ( e.g. using this PPA on Ubuntu for 7.2 ). But I think it's worth it.

๐Ÿ‘ป Brief Description

The default recipe pulls in Apache on Ubuntu 20.04 (it doesn't on Ubuntu < 20.04)

The problem can be solved by specifying specific versions for node['php']['packages'], similar to what is in attributes/default.rb for versions of Ubuntu other that 20.04.

default['php']['packages']         = %w(php7.4-cgi php7.4 php7.4-dev php7.4-cli php-pear)

๐Ÿฅž Cookbook version

v8.0.0

๐Ÿ‘ฉโ€๐Ÿณ Chef-Infra Version

chef 14.15.6

๐ŸŽฉ Platform details

Ubuntu 20.04

Steps To Reproduce

Steps to reproduce the behavior:

  1. converge default recipe
  2. dpkg -l | grep apache

๐Ÿš“ Expected behavior

Apache not being pulled in as a dep.

๐Ÿ—ฃ๏ธ Foreword

Hi, I'm having a problem to install a pecl because I can't answer the prompted questions.

:person_frowning: Problem Statement

When installing the pecl redis (https://pecl.php.net/package/redis) on the command line with pecl install redis, I get prompted some questions (in this case, to enable igbinary serializer support):

# pecl install redis
downloading redis-3.1.6.tgz ...
Starting to download redis-3.1.6.tgz (199,920 bytes)
..............done: 199,920 bytes
20 source files, building
running: phpize
Configuring for:
PHP Api Version:         20131106
Zend Module Api No:      20131226
Zend Extension Api No:   220131226
enable igbinary serializer support? [no] :

I need to somehow answer yes to this question.

โ” Possible Solution

Allow me to answer yes to the question. One option on the command line is yes | pecl install redis

โคด๏ธ Describe alternatives you've considered

I didn't managed to get it working by playing with the available options.

โž• Additional context

At the moment I install it with php_pear like so:

php_pear "redis" do
  action :install
  version "5.2.2"
  channel 'pecl.php.net'
end

Description

php.ini for CentOS, RedHat and Ubuntu are missing request_order, defaulting it to variables_order, which is set to EGPCS.

http://php.net/manual/en/ini.core.php says that

...the default distribution php.ini files does not contain the 'C' for cookies, due to security concerns.

I would like to understand why the variable is missing from the template for these distributions and, if possible, what are the potential security issues that might come from have 'C' in the list.

๐Ÿ—ฃ๏ธ Foreword

Thank for taking the time to fill this feature request fully. Without it we may not be able to , and the issue may be closed without resolution.

๐Ÿ™ Problem Statement

After #250 was merged, i noticed that this cookbook supplies distro-specific php.ini templates for debian, ubuntu, centos and redhat. Things could be greatly simplified by removing these and, if needed at all, set any distro-specific ini defaults in a different way using the default template.

This issue was also addressed in #150 but this issue got closed due to inactivity.

โ” Possible Solution

Remove distro-specific php.ini templates. If needed at all, set any distro-specific ini defaults in a different way using the default template.

โคด๏ธ Describe alternatives you've considered

Update all of the distro specific templates too as addressed in #250 but that seems very cludgy.

โž• Additional context

#150
#250

๐Ÿ‘ป (Not A) Brief Description

When trying to install PHP7.2 from SCL on CentOS 7, installing a pecl package (imagick for example) using the php_pear resource fails because the dependencies cannot be found even when they are installed. But SSH-ing into the machine and running pecl install imagick via command line, runs without issue.

I think I've narrowed down the problem to the usage of shell_out() and how it handles the PATH environment variable. Calling it without the { default_env: false } flag causes the chef-client to inject /opt/chef/embedded/bin to the beginning of the $PATH so that when command runs, it picks up the pkg-config embedded in Chef instead of the one installed on the system.

Calling shell_out() without the flag: checking for pkg-config... /opt/chef/embedded/bin/pkg-config

Calling shell_out() with the flag: checking for pkg-config... /usr/bin/pkg-config

I can't figure out why it works without problems when using the default php version installed by CentOS, but either way I think that php_pear should explicitly tell chef-client to not muck with $PATH for consistency. Even the execute resource uses this flag to have the output match what you would see if you were to run it manually via command line (See: https://github.com/chef/chef/blob/master/lib/chef/resource/execute.rb#L72).

I'm not sure if this would break for other platforms, but it seems to work fine when updating calls to shell_out() to include this flag. Example below:

def pear_shell_out(command)
  p = shell_out!(command, { default_env: false })
  # pear/pecl commands return a 0 on failures...we'll grep for it
  p.invalid! if p.stdout.split('\n').last =~ /^ERROR:.+/i
  p
end

For reference:

๐Ÿฅž Cookbook version

7.0.0

๐Ÿ‘ฉโ€๐Ÿณ Chef-Infra Version

Chef 14.2+

EDIT (2020-02-20):

I'm not sure how to comment further so I'm making an edit here...

Sorry, I wasn't clear. The default_env flag is true by default in Chef 14. The fix that I suggested is to modify the pear_shell_out() method (https://github.com/sous-chefs/php/blob/master/resources/pear.rb#L187) to call shell_out()! with { default_env: false } flag.

The problem only occurs when using a PHP version provided in SCL (e.g.: CentOS 7 running PHP7.2 from SCL). In order to install PHP7.2 I've overridden a lot of the default attributes.

Overrides for reference:

override['php']['packages'] = %w(rh-php72 rh-php72-php-devel rh-php72-php-json rh-php72-php-ldap rh-php72-php-mbstring rh-php72-php-mysqlnd rh-php72-php-opcache rh-php72-php-pdo rh-php72-php-xml)
override['php']['pear'] = '/opt/rh/rh-php72/root/bin/pear'
override['php']['conf_dir'] = '/etc/opt/rh/rh-php72'
override['php']['ext_conf_dir'] = '/etc/opt/rh/rh-php72/php.d'
override['php']['ext_dir'] = '/opt/rh/rh-php72/root/usr/lib64/php/modules'
override['php']['fpm_package'] = 'rh-php72-php-fpm'
override['php']['fpm_pooldir'] = '/etc/opt/rh/rh-php72/php-fpm.d'
override['php']['fpm_default_conf'] = '/etc/opt/rh/rh-php72/php-fpm.d/www.conf'
override['php']['fpm_service'] = 'rh-php72-php-fpm'

To be clear, when using the default PHP that is provided by CentOS 7 (i.e.: without using SCL), there are no issues. I've tested the fix and it works fine for my use case, but I'm not sure if it will break on other platforms.

๐Ÿ—ฃ๏ธ Foreword

Thank for taking the time to fill this feature request fully. Without it we may not be able to , and the issue may be closed without resolution.

๐Ÿ™ Problem Statement

It is not possible to add pear channels that require authentication

โ” Possible Solution

  • Add a sensitive aware value in the pear_channel resource to allow for adding usernames and passwords

โคด๏ธ Describe alternatives you've considered

  • Not doing it?

It is not a bug or feature rather a question. Is there any way i can use amazon-linux-extras to install php 7.2 on amazon linux 2.

๐Ÿ‘ป Brief Description

The priority of extensions is entered as a parameter but not rendered on the template

๐Ÿฅž Cookbook version

7.1.0

๐Ÿ‘ฉโ€๐Ÿณ Chef-Infra Version

16.1.16

๐ŸŽฉ Platform details

Ubuntu 20.04

Steps To Reproduce

Pass a priority to the resource php_pear:

php_pear 'raphf' do
  action :install
  version '2.0.1'
  channel 'pecl.php.net'
  priority '99'
end

Verify that the extension file created does NOT contain the given priority.

๐Ÿš“ Expected behavior

A line with the priority (on this specific format) in the extension file created

; priority=99

I am installing php from source (5.4.32) on Centos 6.5. I then try to run the following:

php_pear "apc" do
    action :install
end

Which appears to be successful (no errors reported), however apc.so is nowhere to be found on my system.

I tried to install it manually by running sudo pecl install apc, and it compiles fine, but again, apc.so is nowhere to be found. It appears that it is installing the extension under /tmp/pear/temp/pear-build-rootJlliUZ/install-APC-3.1.13 but that directory ceases to exist once the install is complete.

The extension dir in php.ini: /usr/lib64/php/modules
Additional .ini files parsed: /etc/php.d/apc.ini

php_pear 'apc' do
  action :install
  directives(node['mycookbook']['apc_directives'])
end

This installs APC but only updates /etc/php5/conf.d/apc.ini according to node['mycookbook']['apc_directives'] if APC was not already installed. Is there a workaround for this?

There is an extensions template that looks to be used for packages installed with Pear but it is not possible to use it for extensions installed via the node[:php][:packages] attribute. It would be handy to have another attribute to define configuration directives for these package installed extensions, which could be used in the extensions.ini template.

Xdebug.ini is not generated with the directive zend_extension='/usr/lib/php5/20121212/xdebug.so' but extension='/usr/lib/php5/20121212/xdebug.so'.

See /providers/pear.rb
This is because we are comparing the output of
(pear.rb:196) pecl config-get ext_dir : /usr/lib/php5/20121212+lfs
to the output of
(pear.rb:204) pecl list-files xdebug : src /usr/lib/php5/20121212/xdebug.so

the resulting value for the zend flag if false.

On solution could be reverting back to
(pear.rb: 195) p = shell_out("php-config --extension-dir")

Is it possible to add an option to make alldeps an optional option for the command. It installs some requirements by default, which I'd rather install with a different method sometimes.

Is there a way to set pear config for example proxy?

Can anyone provide me a sample how can i update the php,ini variable to override the existing settings

At this time, due to bugs in yum_package (chef/chef#3332) it is impossible to define which version of php you want to install from package.

It would be useful if you would change the packages attribute to be a Hash which would allow version and options per package, with a default used by each if not overridden.

I choose to make PHP from source, so I can use an earlier PHP version (5.3). Make fails due to https://bugs.php.net/bug.php?id=69055

PHP suggest to use earlier version of bison. is it possible to provide an option in this recipe to install an earlier version?

The per platform template functionality in Chef is not entirely deprecated, but hasn't been updated to support things like platform_family. By using this we're not providing platform specific templates for debian and redhat derivatives. We should do this in a different way so each platform gets the appropriate template.

I'm trying to do load an extension that depends on another extension, but comes earlier in the alphabet. so I need to set a lower priority for my extension. I am trying to install couchbase which depends on json.

so I'd think something like this would be nice:

php_pear "couchbase" do
  action :install
  priority "25"
end

If no one has any other ideas, I may push this as a merge request next week, just looking to see if there is another option and feeling out if there would be push back.