Adoptable Cookbooks List

Looking for a cookbook to adopt? You can now see a list of cookbooks available for adoption!
List of Adoptable Cookbooks

Supermarket Belongs to the Community

Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the Chef Mailing List.

Select Badges

Select Supported Platforms


php (58) Versions 7.0.0

Installs and maintains php and php modules

cookbook 'php', '~> 7.0.0'
cookbook 'php', '~> 7.0.0', :supermarket
knife supermarket install php
knife supermarket download php
Quality 100%

php Cookbook

Cookbook Version Build Status OpenCollective OpenCollective License

It installs and configures PHP and the PEAR package management system. Also includes resources for managing PEAR (and PECL) packages, PECL channels, and PHP-FPM pools.


This cookbook is maintained by the Sous Chefs. The Sous Chefs are a community of Chef cookbook maintainers working together to maintain important cookbooks. If you’d like to know more please visit or come chat with us on the Chef Community Slack in #sous-chefs.



  • Debian, Ubuntu
  • CentOS, Red Hat, Oracle, Scientific, Amazon Linux
  • Fedora


  • Chef 14+


  • node['php']['install_method'] = method to install php with, default package.
  • node['php']['directives'] = Hash of directives and values to append to php.ini, default {}.
  • node['php']['pear_setup'] = Boolean value to determine whether to set up pear repositories. Default: true
  • node['php']['pear_channels'] = List of external pear channels to add if node['php']['pear_setup'] is true. Default: ['', '']

The file also contains the following attribute types:

  • platform specific locations and settings.
  • source installation settings


This cookbook includes resources for managing:

  • PEAR channels
  • PEAR/PECL packages


PEAR Channels are alternative sources for PEAR packages. This resource provides and easy way to manage these channels.


  • :discover: Initialize a channel from its server.
  • :add: Add a channel to the channel list, usually only used to add private channels. Public channels are usually added using the :discover action
  • :update: Update an existing channel
  • :remove: Remove a channel from the List


  • channel_name: name attribute. The name of the channel to discover
  • channel_xml: the channel.xml file of the channel you are adding
  • binary: pear binary, default: pear


# discover the horde channel
php_pear_channel "" do
  action :discover

# download xml then add the symfony channel
remote_file "#{Chef::Config[:file_cache_path]}/symfony-channel.xml" do
  source ''
  mode '0644'
php_pear_channel 'symfony' do
  channel_xml "#{Chef::Config[:file_cache_path]}/symfony-channel.xml"
  action :add

# update the main pear channel
php_pear_channel '' do
  action :update

# update the main pecl channel
php_pear_channel '' do
  action :update


PEAR is a framework and distribution system for reusable PHP components. PECL is a repository for PHP Extensions. PECL contains C extensions for compiling into PHP. As C programs, PECL extensions run more efficiently than PEAR packages. PEARs and PECLs use the same packaging and distribution system. As such this resource is clever enough to abstract away the small differences and can be used for managing either. This resource also creates the proper module .ini file for each PECL extension at the correct location for each supported platform.


  • :install: Install a pear package - if version is provided, install that specific version
  • :upgrade: Upgrade a pear package - if version is provided, upgrade to that specific version
  • :remove: Remove a pear package
  • :reinstall: Force install of the package even if the same version is already installed. Note: This will converge on every Chef run and is probably not what you want.
  • :purge: An alias for remove as the two behave the same in pear


  • package_name: name attribute. The name of the pear package to install
  • version: the version of the pear package to install/upgrade. If no version is given latest is assumed.
  • channel:
  • options: Add additional options to the underlying pear package command
  • directives: extra extension directives (settings) for a pecl. on most platforms these usually get rendered into the extension's .ini file
  • zend_extensions: extension filenames which should be loaded with zend_extension.
  • preferred_state: PEAR by default installs stable packages only, this allows you to install pear packages in a devel, alpha or beta state
  • binary: The pear binary to use, by default pear, can be overridden if the binary is not called pear, e.g. pear7


# upgrade a pear
php_pear 'XML_RPC' do
  action :upgrade

# install a specific version
php_pear 'XML_RPC' do
  version '1.5.4'
  action :install

# install the mongodb pecl
php_pear 'Install mongo but use a different resource name' do
  package_name 'mongo'
  action :install

# install the xdebug pecl
php_pear 'xdebug' do
  # Specify that must be loaded as a zend extension
  zend_extensions ['']
  action :install

# install apc pecl with directives
php_pear 'apc' do
  action :install
  directives(shm_size: 128, enable_cli: 1)

# install using the pear-7 binary
php_pear 'apc' do
  action :install
  binary 'pear7'

# install sync using the pecl binary
php_pear 'sync' do
  version '1.1.1'
  binary 'pecl'

# install sync using the pecl channel
php_pear 'sync' do
  version '1.1.1'
  channel ''

# install the beta version of Horde_Url
# from the horde channel
hc = php_pear_channel '' do
  action :discover

php_pear 'Horde_Url' do
  preferred_state 'beta'
  channel hc.channel_name
  action :install

# install the YAML pear from the symfony project
sc = php_pear_channel '' do
  action :discover

php_pear 'YAML' do
  channel sc.channel_name
  action :install


Installs the php-fpm package appropriate for your distro (if using packages) and configures a FPM pool for you. Currently only supported in Debian-family operating systems and CentOS 7 (or at least tested with such, YMMV if you are using source).

Please consider FPM functionally pre-release, and test it thoroughly in your environment before using it in production

More info:


  • :install: Installs the FPM pool (default).
  • :uninstall: Removes the FPM pool.

Attribute Parameters

  • pool_name: name attribute. The name of the FPM pool.
  • listen: The listen address. Default: /var/run/php5-fpm.sock
  • user: The user to run the FPM under. Default should be the webserver user for your distro.
  • group: The group to run the FPM under. Default should be the webserver group for your distro.
  • process_manager: Process manager to use - see Default: dynamic
  • max_children: Max children to scale to. Default: 5
  • start_servers: Number of servers to start the pool with. Default: 2
  • min_spare_servers: Minimum number of servers to have as spares. Default: 1
  • max_spare_servers: Maximum number of servers to have as spares. Default: 3
  • chdir: The startup working directory of the pool. Default: /
  • additional_config: Additional parameters in JSON. Default: {}


# Install a FPM pool named "default"
php_fpm_pool 'default' do
  action :install



Include the default recipe in a run list, to get php. By default php is installed from packages but this can be changed by using the install_method attribute.


This recipe installs PHP from packages.


This recipe installs PHP from source.


Simply include the php recipe where ever you would like php installed. To install from source override the node['php']['install_method'] attribute with in a role or wrapper cookbook:

Role example

name 'php'
description 'Install php from source'
  'php' => {
    'install_method' => 'source',


This project exists thanks to all the people who contribute.


Thank you to all our backers!


Support this project by becoming a sponsor. Your logo will show up here with a link to your website.

Dependent cookbooks

yum-epel >= 0.0.0

Contingent cookbooks

aegir Applicable Versions
aegir2 Applicable Versions
aegir3 Applicable Versions
application Applicable Versions
application_php Applicable Versions
application_zf Applicable Versions
aws-php-elasticache Applicable Versions
beanstalk-console Applicable Versions
beanstalkd Applicable Versions
boilerplate_php Applicable Versions
boxbilling Applicable Versions
bricks Applicable Versions
cakephp Applicable Versions
composer Applicable Versions
drupal Applicable Versions
dvwa Applicable Versions
elefant Applicable Versions
frontaccounting Applicable Versions
gallery Applicable Versions
gotcms Applicable Versions
ish Applicable Versions
ish_mediawiki Applicable Versions
jenkins-php Applicable Versions
lamp_role Applicable Versions
laravel Applicable Versions
logstash Applicable Versions
lxmpbox Applicable Versions
magento Applicable Versions
magento-toolbox Applicable Versions
magerun Applicable Versions
mediawiki Applicable Versions
myface Applicable Versions
nagios Applicable Versions
newrelic Applicable Versions
newrelic-ng Applicable Versions
opencart Applicable Versions
oracle-instantclient Applicable Versions
owncloud Applicable Versions
pdepend Applicable Versions
phabricator Applicable Versions
phing Applicable Versions
php-box Applicable Versions
php-fpm Applicable Versions
php-ioncube Applicable Versions
php-mcrypt Applicable Versions
php-omnibus Applicable Versions
php5-mysql Applicable Versions
php_wrapper Applicable Versions
phpbb Applicable Versions
phpcb Applicable Versions
phpcpd Applicable Versions
phpcs Applicable Versions
phpdcd Applicable Versions
phpdoc Applicable Versions
phploc Applicable Versions
phpmd Applicable Versions
phpmyadmin Applicable Versions
phpstack Applicable Versions
phpunit Applicable Versions
pinba Applicable Versions
postfixadmin Applicable Versions
rackspace_apache_php Applicable Versions
rackspace_nginx_php Applicable Versions
rainloop Applicable Versions
roundcube Applicable Versions
stack_commons Applicable Versions
sugar_crm Applicable Versions
sugarcrm Applicable Versions
sugarcrm-ce Applicable Versions
sugarcrm_ce Applicable Versions
suhosin Applicable Versions
symfony Applicable Versions
teampass Applicable Versions
teamspeak Applicable Versions
testswarm Applicable Versions
tideways Applicable Versions
toran Applicable Versions
vicnum Applicable Versions
wordpress Applicable Versions
xdebug Applicable Versions
ya-piwik Applicable Versions
yourls Applicable Versions
zabbix Applicable Versions
zabbix-pkg Applicable Versions
zf2 Applicable Versions


This file is used to list changes made in each version of the PHP cookbook.


7.0.0 (2019-08-07)

  • Drop support for Chef 13 so we don't need to require build essentials
  • Sync php.ini template with php.ini-production from php-7.2.18

6.1.1 (2018-08-07)

  • Pass in missing argument to manage_pecl_ini method when trying to remove a module

6.1.0 (2018-07-24)

  • Allow default recipe to skip pear channel configuration

6.0.0 (2018-04-16)

Breaking Change

This release removes the previous recipes in this cookbook for setting up various PEAR extensions. These should now be setup using the php_pear module directly and not done by adding various recipes / manipulating attributes

Other Changes

  • Use the build_essential resource directly so we can call this from Chef itself on Chef 14
  • Add specs for additional platforms
  • Move the helpers back into the resources which makes them easier to ship in Chef later
  • Break out logic in the channel resource into a helper
  • Add support for Amazon Linux 2

5.1.0 (2018-04-05)

  • Don't eval the action_class
  • use php pear binary property in all recipes
  • Remove incorrect not_if in the php_pear resource
  • More testing updates
  • Initial support for Ubuntu 18.04

5.0.0 (2018-02-15)

  • Simplify this cookbook to remove the dependency on mysql cookbook, and remove the database dependencies in the recipes and attributes. This will allow folks who are using the mysql cookbook to be able to upgrade as needed (or pin to earlier versions). As this is a big change, pin to an earlier version if you need the mysql support that was previously available in this cookbook. Future versions may contain a resource that allows for recompiling php with the necessary extensions.
  • Usage of node['php']['pear'] in the php_pear resource has been replaced with a new 'binary' property for specifying the path to the binary
  • Added a new priority property to the php_pear resource

4.6.0 (2018-02-07)

  • Converted the php_pear resource to a custom resource
  • Moved all helper logic out of the resource and into its own helper library file
  • Fix source install on Ubuntu by making sure we have xml2-config package
  • Remove options that are no longer recognised by the php installer when installing from source
  • Remove matchers as we no longer require them with a modern ChefDK

4.5.0 (2017-07-11)

  • Add reinstall chefspec matcher
  • Switch from maintainers files to a simple readme section
  • Remove allow_call_time_pass_reference and y2k_compliance config on Debian/Ubuntu as no supported PHP version supports it
  • Initial Debian 9 support

4.4.0 (2017-06-27)

  • Add a reinstall action to php_pear
  • Added additional specs for package installs on different platforms

4.3.0 (2017-06-27)

  • Remove fallback default php attributes that were used if we were on an unsupported platform. If we don't know the platform we don't support it and we should fail until we add proper support
  • Add a few attributes needed for fpm support on opensuse. This is a work in progress to get full PHP support on opensuse
  • Install xml deps and avoid using xml cookbook since it's been deprecated
  • Expand the php_pear testing
  • Remove double logging and log the correct package name in php_pear resource
  • Cleanup readme example codes, improve formatting and remove references to LWRPs as they are just resources now

4.2.0 (2017-05-30)

  • Make sure package intalls, php-fpm, and source installs work on Amazon linux
  • Avoid symlink warning in the converges
  • Simplify the package install logic
  • Rename the inspec test to match the suite name so it actually runs
  • Test on FreeBSD 11 / Amazon Linux
  • Install 5.6.30 by default on source installs

4.1.0 (2017-05-30)

  • Remove class_eval usage and require Chef 12.7+

4.0.0 (2017-04-20)

  • Fix pear_channel resource to not fail on Chef 12.5 and 12.6
  • Remove support for RHEL 5 as it is now EOL
  • Resolve Amazon Linux failures on Chef 13
  • Convert fpm_pool to a custom resource
  • Fix php_pear failures on Chef 13
  • Remove non-functional support for Windows
  • Remove redundant Ubuntu version checks in the php_pear provider
  • Expand testing to test all of the resources

3.1.1 (2017-04-20)

  • Use the cookbook attribute as the default value of pear_channel pear property to provide better platform support

3.1.0 (2017-04-10)

  • Use multi-package installs on supported platform_family(rhel debian suse amazon)
  • Use a SPDX standardized license string in the metadata
  • Update specs for the new Fauxhai data

3.0.0 (2017-03-27)

  • Converted pear_channel LWRP into custom resource
  • Removed use of pear node attribute from pear_channel resource
  • Fix cookstyle issue with missing line on metadata.rb
  • Clean up kitchen.dokken.yml file to eliminate duplication of testing suites.
  • Eliminate duplicated resource from test cookbook that is in the default recipe.
  • Rename php-test to standard cookbook testing cookbook of "test"
  • Remove EOL ubuntu platform logic

NOTE Windows package installation is currently broken.

2.2.1 (2017-02-21)

  • Fix double definition of ['php']['packages'] for rhel.

2.2.0 (2016-12-12)

  • Use multipackage for installs to speed up chef runs
  • Use all CPUs when building from source
  • Remove need for apt/yum in testing
  • Add opensuse to the metadata
  • Migrate to inspec for integration testing

2.1.1 (2016-09-15)

  • Fix recompile un-pack php creates
  • Resolve cookstyle warnings

2.1.0 (2016-09-14)

  • Fix source php version check
  • Require Chef 12.1 not 12.0

2.0.0 (2016-09-07)

  • Require Chef 12+
  • Remove the dependency on the Windows cookbook which isn't necessary with Chef 12+

1.10.1 (2016-08-30)

  • [fix] bug fixes related with Ubuntu 16.04 and PHP 7 support
  • adding validator to listen attribute
  • Fix warnings

v1.10.0 (2016-07-27)

  • PR #167 Preventing user specified pool of www from being deleted at the end of the chef run on the first install
  • PR #122 Add recipe for php module_imap
  • PR #172 Fix uninstall action for resource php_fpm_pool

v1.9.0 (2016-05-12)

Special thanks to @ThatGerber for getting the PR for this release together

  • Added support for Ubuntu 16.04 and PHP 7
  • Added support for different listen user/groups with FPM
  • Cleaned up resource notification in the pear_channel provider to simplify code
  • Fixed Ubuntu 14.04+ not being able to find the GMP library

v1.8.0 (2016-02-25)

  • Bumped the source install default version from 5.5.9 to 5.6.13
  • Added a chefignore file to limit the files uploaded to the Chef server
  • Added source_url and issues_url to the metadata.rb
  • Added additional Chefspec matchers
  • Added a Chef standard rubocop.yml file and resolved warnings
  • Added serverspec for integration testing
  • Remove legacy cloud Test Kitchen configs
  • Added testing in Travis CI with kitchen-docker
  • Added additional test suites to the Test Kitchen config
  • Updated contributing and testing documentation
  • Updated testing gem dependencies to the latest
  • Added and maintainers.toml files
  • Remove gitter chat from the readme
  • Add cookbook version badge to the readme
  • Added Fedora as a supported platform in the readme
  • Add missing cookbook dependencies to the readme

v1.7.2 (2015-8-24)

  • Correct spelling in fpm_pool_start_servers (was servres)

v1.7.1 (2015-8-17)

  • Correct permissions on ext_conf_dir folder (644 -> 755)

v1.7.0 (2015-7-31)

  • NOTICE - This version changes the way the ['php']['directives'] is placed into configuration files. Quotes are no longer automatically placed around these aditional directives. Please take care when rolling out this version.
  • Allow additional PHP FPM config
  • Add recipe to recompile PHP from source
  • Move source dependencies to attributes file
  • Misc bug fixes

v1.6.0 (2015-7-6)

  • Added ChefSpec matchers
  • Added basic PHP-FPM Support (Pre-Release)
  • Added support for FreeBSD
  • Updated cookbook to use MySQL 6.0 cookbook
  • Update cookbook to use php5enmod on supported platforms
  • Allow users to override php-mysql package

v1.5.0 (2014-10-06)

  • Adding package_options attribute, utilizing in package resource

v1.4.6 (2014-03-19)

  • [COOK-4436] - Test this cookbook, not yum. Also test Fedora 20.
  • [COOK-4427] - Add oracle as supported operating system

v1.4.4 (2014-03-12)

  • [COOK-4393] - Fix convergence bug in source install

v1.4.2 (2014-02-27)

[COOK-4300] - Simplified and fixed pear/pecl logic. [Fixes #56 / #57]

v1.4.0 (2014-02-27)

[COOK-3639] - Allow users to specify php.ini source template

v1.3.14 (2014-02-21)


  • COOK-4186 - Upgrade_package concatenates an empty version string when version is not set or is empty.

v1.3.12 (2014-01-28)

Fix github issue 'Cannot find a resource for preferred_state'


Fixing my stove


Version bump to ensure artifact sanity


Version bump for toolchain


Adding platform_family check to include_recipe in source.rb


Fixing style cops. Updating test harness



  • COOK-3479 - Added Windows support to PHP
  • COOK-2909 - Warnings about Chef::Exceptions::ShellCommandFailed is deprecated



  • COOK-3628 - Fix PHP download URL
  • COOK-3568 - Fix Test Kitchen tests
  • COOK-3402 - When the ext_dir setting is present, configure php properly for the source recipe
  • COOK-2926 - Fix pear package detection when installing specific version



  • COOK-3047 - Sort directives in php.ini
  • COOK-2928 - Abstract php.ini directives into variables




  • [COOK-3050]: lib_dir declared in wrong place for redhat
  • [COOK-3102]: remove fileinfo recipe from php cookbook


  • [COOK-3101]: use a method to abstract range of "el 5" versions in php recipes



  • [COOK-2516]: Better support for SUSE distribution for php cookbook
  • [COOK-3035]: update php::source to install 5.4.15 by default


  • [COOK-2463]: PHP PEAR Provider Installs Most Recent Version, Without Respect to Preferred State
  • [COOK-2514]: php_pear: does not handle more exotic version strings


  • [COOK-1998] - Enable override of PHP packages in attributes


  • [COOK-2324] - adds Oracle linux support


  • [COOK-2106] - php_pear cannot find available packages


  • [COOK-1803] - use better regexp to match package name
  • [COOK-1926] - support Amazon linux


  • [COOK-543] - php.ini template should be configurable
  • [COOK-1067] - support for PECL zend extensions
  • [COOK-1193] - update package names for EPEL 6
  • [COOK-1348] - rescue Mixlib::ShellOut::ShellCommandFailed (chef 0.10.10)
  • [COOK-1465] - fix pear extension template


  • [COOK-993] Add mhash-devel to centos php source libs
  • [COOK-989] - bump version of php to 5.3.10
  • Also download the .tar.gz instead of .tar.bz2 as bzip2 may not be in the base OS (e.g., CentOS 6 minimal)

Collaborator Number Metric

7.0.0 passed this metric

Contributing File Metric

7.0.0 passed this metric

Foodcritic Metric

7.0.0 passed this metric

No Binaries Metric

7.0.0 passed this metric

Publish Metric

7.0.0 passed this metric

Supported Platforms Metric

7.0.0 passed this metric

Testing File Metric

7.0.0 passed this metric

Version Tag Metric

7.0.0 passed this metric