{"id":13405499,"url":"https://github.com/voxpupuli/puppet-php","last_synced_at":"2025-04-11T16:37:14.248Z","repository":{"id":14247291,"uuid":"16954722","full_name":"voxpupuli/puppet-php","owner":"voxpupuli","description":"Generic Puppet module to manage PHP on many platforms","archived":false,"fork":false,"pushed_at":"2025-04-09T15:07:28.000Z","size":1670,"stargazers_count":87,"open_issues_count":120,"forks_count":269,"subscribers_count":59,"default_branch":"master","last_synced_at":"2025-04-11T16:37:10.067Z","etag":null,"topics":["archlinux-puppet-module","bsd-puppet-module","centos-puppet-module","debian-puppet-module","freebsd-puppet-module","hacktoberfest","linux-puppet-module","puppet","redhat-puppet-module","sles-puppet-module","ubuntu-puppet-module"],"latest_commit_sha":null,"homepage":"http://forge.puppet.com/puppet/php","language":"Puppet","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/voxpupuli.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"open_collective":"vox-pupuli","github":"voxpupuli"}},"created_at":"2014-02-18T16:06:24.000Z","updated_at":"2025-04-09T15:07:33.000Z","dependencies_parsed_at":"2023-12-15T04:03:50.866Z","dependency_job_id":"220c3834-b4cc-40ff-b470-513593923d11","html_url":"https://github.com/voxpupuli/puppet-php","commit_stats":{"total_commits":1072,"total_committers":175,"mean_commits":"6.1257142857142854","dds":0.853544776119403,"last_synced_commit":"9c3cfb33477e759a0c70b33853886f489f5d7157"},"previous_names":["mayflower/puppet-php"],"tags_count":45,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voxpupuli%2Fpuppet-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voxpupuli%2Fpuppet-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voxpupuli%2Fpuppet-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voxpupuli%2Fpuppet-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/voxpupuli","download_url":"https://codeload.github.com/voxpupuli/puppet-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248441584,"owners_count":21104024,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["archlinux-puppet-module","bsd-puppet-module","centos-puppet-module","debian-puppet-module","freebsd-puppet-module","hacktoberfest","linux-puppet-module","puppet","redhat-puppet-module","sles-puppet-module","ubuntu-puppet-module"],"created_at":"2024-07-30T19:02:03.938Z","updated_at":"2025-04-11T16:37:14.225Z","avatar_url":"https://github.com/voxpupuli.png","language":"Puppet","readme":"[![Puppet Forge](http://img.shields.io/puppetforge/v/puppet/php.svg)](https://forge.puppetlabs.com/puppet/php)\n\n# voxpupuli/php Puppet Module\n\nvoxpupuli/php is a Puppet module for managing PHP with a strong focus\non php-fpm. The module aims to use sane defaults for the supported\narchitectures. We strive to support all recent versions of Debian,\nUbuntu, RedHat/CentOS, openSUSE/SLES and FreeBSD. Managing Apache\nwith `mod_php` is not supported.\n\nThis originally was a fork of [jippi/puppet-php](https://github.com/jippi/puppet-php)\n(nodes-php on Puppet Forge) but has since been rewritten in large parts.\n\n## Usage\n\nQuickest way to get started is simply `include`'ing the _`php` class_.\n\n```puppet\ninclude 'php'\n```\n\nOr, you can override defaults and specify additional custom\nconfigurations by declaring `class { 'php': }` with parameters:\n\n```puppet\nclass { 'php':\n  ensure       =\u003e latest,\n  manage_repos =\u003e true,\n  fpm          =\u003e true,\n  dev          =\u003e true,\n  composer     =\u003e true,\n  pear         =\u003e true,\n  phpunit      =\u003e false,\n}\n```\n\nOptionally the PHP version or configuration root directory can be changed also:\n\n```puppet\nclass { 'php::globals':\n  php_version =\u003e '7.0',\n  config_root =\u003e '/etc/php/7.0',\n}-\u003e\nclass { 'php':\n  manage_repos =\u003e true\n}\n```\n\nThere are more configuration options available. Please refer to the\nauto-generated documentation at [REFERENCE.md](REFERENCE.md).\n\n### Defining `php.ini` settings\n\nPHP configuration parameters in `php.ini` files can be defined as parameter\n`settings` on the main `php` class, or `php::fpm` / `php::cli` classes,\nor `php::extension` resources for each component independently.\n\nThese settings are written into their respective `php.ini` file. Global\nsettings in `php::settings` are merged with the settings of all components.\nPlease note that settings of extensions are always independent.\n\nIn the following example the PHP options and timezone will be set in\nall PHP configurations, i.e. the PHP cli application and all php-fpm pools.\n\n```puppet\n  class { 'php':\n    settings   =\u003e {\n      'PHP/max_execution_time'  =\u003e '90',\n      'PHP/max_input_time'      =\u003e '300',\n      'PHP/memory_limit'        =\u003e '64M',\n      'PHP/post_max_size'       =\u003e '32M',\n      'PHP/upload_max_filesize' =\u003e '32M',\n      'Date/date.timezone'      =\u003e 'Europe/Berlin',\n    },\n  }\n```\n\n### Installing extensions\n\nPHP configuration parameters in `php.ini` files can be defined\nas parameter `extensions` on the main `php` class. They are\nactivated for all activated SAPIs.\n\n```puppet\n  class { 'php':\n    extensions =\u003e {\n      bcmath    =\u003e { },\n      imagick   =\u003e {\n        provider =\u003e pecl,\n      },\n      xmlrpc    =\u003e { },\n      memcached =\u003e {\n        provider        =\u003e 'pecl',\n        header_packages =\u003e [ 'libmemcached-devel', ],\n      },\n      apc       =\u003e {\n        provider =\u003e 'pecl',\n        settings =\u003e {\n          'apc/stat'       =\u003e '1',\n          'apc/stat_ctime' =\u003e '1',\n        },\n        sapi     =\u003e 'fpm',\n      },\n    },\n  }\n```\n\nSee [the documentation](REFERENCE.md#php--extension) of the `php::extension`\nresource for all available parameters and default values.\n\n### Defining php-fpm pools\n\nIf different php-fpm pools are required, you can use `php::fpm::pool`\ndefined resource type. A single pool called `www` will be configured\nby default. Specify additional pools like so:\n\n```puppet\n  php::fpm::pool { 'www2':\n    listen =\u003e '127.0.1.1:9000',\n  }\n```\n\nFor an overview of all possible parameters for `php::fpm::pool` resources please\nsee [its documentation](REFERENCE.md#php--fpm--pool).\n\n### Overriding php-fpm user\n\nBy default, php-fpm is set up to run as Apache. If you need to customize that user, you can do that like so:\n\n```puppet\n  class { 'php':\n    fpm_user  =\u003e 'nginx',\n    fpm_group =\u003e 'nginx',\n  }\n```\n\n### PHP with one FPM pool per user\n\nThis will create one vhost. $users is an array of people having php files at\n$fqdn/$user. This code uses voxpupuli/php and voxpupuli/nginx to create\nthe vhost and one php fpm pool per user. This was tested on Archlinux with\nnginx 1.13 and PHP 7.2.3.\n\n```puppet\n$users = ['bob', 'alice']\n\nclass { 'php':\n   ensure       =\u003e 'present',\n   manage_repos =\u003e false,\n   fpm          =\u003e true,\n   dev          =\u003e false,\n   composer     =\u003e false,\n   pear         =\u003e true,\n   phpunit      =\u003e false,\n   fpm_pools    =\u003e {},\n}\n\ninclude nginx\n\nnginx::resource::server{$facts['fqdn']:\n  www_root  =\u003e '/var/www',\n  autoindex =\u003e 'on',\n}\nnginx::resource::location{'dontexportprivatedata':\n  server        =\u003e $facts['fqdn'],\n  location      =\u003e '~ /\\.',\n  location_deny =\u003e ['all'],\n}\n$users.each |$user| {\n  # create one fpm pool. will be owned by the specific user\n  # fpm socket will be owned by the nginx user 'http'\n  php::fpm::pool{$user:\n    user         =\u003e $user,\n    group        =\u003e $user,\n    listen_owner =\u003e 'http',\n    listen_group =\u003e 'http',\n    listen_mode  =\u003e '0660',\n    listen       =\u003e \"/var/run/php-fpm/${user}-fpm.sock\",\n  }\n  nginx::resource::location { \"${name}_root\":\n    ensure      =\u003e 'present',\n    server      =\u003e $facts['fqdn'],\n    location    =\u003e \"~ .*${user}\\/.*\\.php$\",\n    index_files =\u003e ['index.php'],\n    fastcgi     =\u003e \"unix:/var/run/php-fpm/${user}-fpm.sock\",\n    include     =\u003e ['fastcgi.conf'],\n  }\n}\n```\n\n### Alternative examples using Hiera\n\nAlternative to the Puppet DSL code examples above, you may optionally define your PHP configuration using Hiera.\n\nBelow are all the examples you see above, but defined in YAML format for use with Hiera.\n\n```yaml\n---\nphp::ensure: latest\nphp::manage_repos: true\nphp::fpm: true\nphp::fpm_user: 'nginx'\nphp::fpm_group: 'nginx'\nphp::dev: true\nphp::composer: true\nphp::pear: true\nphp::phpunit: false\nphp::settings:\n  'PHP/max_execution_time': '90'\n  'PHP/max_input_time': '300'\n  'PHP/memory_limit': '64M'\n  'PHP/post_max_size': '32M'\n  'PHP/upload_max_filesize': '32M'\n  'Date/date.timezone': 'Europe/Berlin'\nphp::extensions:\n  bcmath: {}\n  xmlrpc: {}\n  imagick:\n    provider: pecl\n  memcached:\n    provider: pecl\n    header_packages:\n      - libmemcached-dev\n  apc:\n    provider: pecl\n    settings:\n      'apc/stat': 1\n      'apc/stat_ctime': 1\n    sapi: 'fpm'\nphp::fpm::pools:\n  www2:\n    listen: '127.0.1.1:9000'\n```\n\n## Notes\n\n### Inheriting configuration across multiple Hiera sources\n\nConfiguration from Hiera such as `php::fpm::pools` is automatically\nlookup up using the \"first\" merge method. This means that the first\nvalue found is used. If you instead want to merge the hash keys\nacross multiple Hiera sources, you can use [`lookup_options`] to\nset [`hash` or `deep` behaviors] such as in the example\n[data/default.yaml](data/default.yaml):\n\n```yaml\nlookup_options:\n  php::fpm::pools:\n    merge: hash\n```\n\n[`lookup_options`]: https://puppet.com/docs/puppet/latest/hiera_merging.html#setting_lookup_options_to_refine_the_result_of_a_lookup\n[`hash` or `deep` behaviors]: https://puppet.com/docs/puppet/latest/hiera_merging.html#merge_behaviors\n\n### Ubuntu systems and Ondřej's PPA\n\nThe older Ubuntu PPAs run by Ondřej have been deprecated (ondrej/php5, ondrej/php5.6)\nin favor of a new PPA: ondrej/php which contains all 3 versions of PHP: 5.5, 5.6, and 7.0\nHere's an example in hiera of getting PHP 5.6 installed with php-fpm, pear/pecl, and composer:\n\n```puppet\nphp::globals::php_version: '5.6'\nphp::fpm: true\nphp::dev: true\nphp::composer: true\nphp::pear: true\nphp::phpunit: false\n```\n\nIf you do not specify a php version, in Ubuntu the default will be 7.0 if you are\nrunning Xenial (16.04), otherwise PHP 5.6 will be installed (for other versions)\n\n### Apache support\n\nApache with `mod_php` is not supported by this module. Please use\n[puppetlabs/apache](https://forge.puppetlabs.com/puppetlabs/apache) instead.\n\nWe prefer using php-fpm. You can find an example Apache vhost in\n`manifests/apache_vhost.pp` that shows you how to use `mod_proxy_fcgi` to\nconnect to php-fpm.\n\n### ZendPHP support\n\n\u003e Be sure to require the `zend/zend_common` puppet module\n\u003e to ensure the correct package repository is being used.\n\nTo use ZendPHP, configure the global zend parameters.\n\n```puppet\nclass { 'php::globals':\n  php_version =\u003e '7.4',\n  flavor      =\u003e 'zend',\n  zend_creds  =\u003e {\n    'username' =\u003e '\u003cUSERNAME\u003e',\n    'password' =\u003e '\u003cPASSWORD\u003e',\n  },\n}-\u003e\nclass { 'php':\n  fpm        =\u003e true,\n  fpm_pools  =\u003e {\n    www      =\u003e {\n      listen =\u003e \"127.0.0.1:9000\",\n    },\n  }\n}\n```\n\n#### ZendPHP soft dependencies on RedHat/CentOS/Rocky\n\nDue to the nature of ZendPHP delivering patched, LTS versions of PHP and its extensions,\nRedHat systems sometimes depend on `epel` and the `powertools` repo.\n\nIf you're trying to use ZendPHP and running into issues of missing dependencies,\nfirst try installing epel. If the dependencies still can't be found, try\nenabling `powertools`.\n\n```puppet\nif $facts['os']['family'] == 'RedHat' {\n  package { 'epel-release': }\n\n  if Float($php_version) \u003c 7.4 {\n    # Depends on puppet/yum\n    class { 'yum':\n      managed_repos =\u003e ['powertools'],\n      repos =\u003e {\n        'powertools' =\u003e {\n          enabled =\u003e true,\n        },\n      },\n    }\n  }\n}\n```\n\n### RedHat/CentOS SCL Users\n\nIf you plan to use the SCL repositories with this module you must do the following adjustments:\n\n#### General config\n\nThis ensures that the module will create configurations in the directory\n`/etc/opt/rh/\u003cphp_version\u003e/` (also in php.d/ for extensions). Anyway you have to\nmanage the SCL repo's by your own.\n\n```puppet\nclass { 'php::globals':\n  php_version =\u003e 'rh-php71',\n  rhscl_mode  =\u003e 'rhscl',\n}\n-\u003e class { 'php':\n  manage_repos =\u003e false\n}\n```\n\n#### Extensions\n\nExtensions in SCL are being installed with packages that cover 1 or more .so files. This is kinda incompatible with\nthis module, since this module specifies an extension by name and derives the name of the package and the config (.ini)\nfrom it. To manage extensions of SCL packages you must use the following parameters:\n\n```puppet\nclass { 'php':\n  ...\n  extensions  =\u003e {\n    'soap' =\u003e {\n      ini_prefix =\u003e '20-',\n    },\n  }\n}\n```\n\nBy this you tell the module to configure bz2 and calender while ensuring only the package `common`. Additionally to the\ninstallation of 'common' the ini files 'calender.ini' and 'bz2.ini' will be created by the scheme\n`\u003cconfig_file_prefix\u003e\u003cextension_title\u003e`.\n\nA list of commonly used modules:\n\n```puppet\n    {\n      extensions =\u003e {\n        'xml' =\u003e {\n          ini_prefix =\u003e '20-',\n          multifile_settings =\u003e true,\n          settings =\u003e {\n            'dom'  =\u003e {},\n            'simplexml' =\u003e {},\n            'xmlwriter' =\u003e {},\n            'xsl' =\u003e {},\n            'wddx' =\u003e {},\n            'xmlreader' =\u003e {},\n          },\n        },\n        'soap' =\u003e {\n          ini_prefix =\u003e '20-',\n        },\n        'imap' =\u003e {\n          ini_prefix =\u003e '20-',\n        },\n        'intl' =\u003e {\n          ini_prefix =\u003e '20-',\n        },\n        'gd' =\u003e {\n          ini_prefix =\u003e '20-',\n        },\n        'mbstring' =\u003e {\n          ini_prefix =\u003e '20-',\n        },\n        'xmlrpc' =\u003e {\n          ini_prefix =\u003e '20-',\n        },\n        'pdo' =\u003e {\n          ini_prefix =\u003e '20-',\n          multifile_settings =\u003e true,\n          settings =\u003e {\n              'pdo'  =\u003e {},\n              'pdo_sqlite' =\u003e {},\n              'sqlite3' =\u003e {},\n            },\n        },\n        'process' =\u003e {\n          ini_prefix =\u003e '20-',\n          multifile_settings =\u003e true,\n          settings =\u003e {\n             'posix'  =\u003e {},\n             'shmop' =\u003e {},\n             'sysvmsg' =\u003e {},\n             'sysvsem' =\u003e {},\n             'sysvshm' =\u003e {},\n          },\n        },\n        'mysqlnd' =\u003e {\n          ini_prefix =\u003e '30-',\n          multifile_settings =\u003e true,\n          settings =\u003e {\n             'mysqlnd'  =\u003e {},\n             'mysql' =\u003e {},\n             'mysqli' =\u003e {},\n             'pdo_mysql' =\u003e {},\n             'sysvshm' =\u003e {},\n          },\n        },\n      }\n    }\n```\n\n### Facts\n\nWe deliver a `phpversion` fact with this module. This is explicitly **NOT** intended\nto be used within your puppet manifests as it will only work on your second puppet\nrun. Its intention is to make querying PHP versions per server easy via PuppetDB or Foreman.\n\n### FreeBSD support\n\nOn FreeBSD systems we purge the system-wide `extensions.ini` in favour of\nper-module configuration files.\n\nPlease also note that support for Composer and PHPUnit on FreeBSD is untested\nand thus likely incomplete.\n\n### Running the test suite\n\nTo run the tests install the ruby dependencies with `bundler` and execute\n`rake`:\n\n```bash\nbundle install --path vendor/bundle\nbundle exec rake\n```\n\n## Bugs \u0026 New Features\n\nIf you happen to stumble upon a bug, please feel free to create a pull request\nwith a fix (optionally with a test), and a description of the bug and how it\nwas resolved.\n\nOr if you're not into coding, simply create an issue adding steps to let us\nreproduce the bug and we will happily fix it.\n\nIf you have a good idea for a feature or how to improve this module in general,\nplease create an issue to discuss it. We are very open to feedback. Pull\nrequests are always welcome.\n\nWe hate orphaned and unmaintained Puppet modules as much as you do and\ntherefore promise that we will continue to maintain this module and keep\nresponse times to issues short. If we happen to lose interest, we will write\na big fat warning into this README to let you know.\n\n## License\n\nThe project is released under the permissive MIT license.\n\nThe source can be found at\n[github.com/voxpupuli/puppet-php](https://github.com/voxpupuli/puppet-php/).\n\nThis Puppet module was originally maintained by some fellow puppeteers at\n[Mayflower GmbH](https://mayflower.de) and is now maintained by\n[Vox Pupuli](https://voxpupuli.org/).\n","funding_links":["https://opencollective.com/vox-pupuli","https://github.com/sponsors/voxpupuli"],"categories":["Puppet"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvoxpupuli%2Fpuppet-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvoxpupuli%2Fpuppet-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvoxpupuli%2Fpuppet-php/lists"}