lukasic.php

Ansible Role: Multi PHP

This Ansible role allows you to install multiple PHP versions on Debian.

Changelog

1.5.1

  • Fixed issue with excluding the JSON module for PHP 8.0 and above.

1.5.0

  • Added support for PHP 8.3.

1.4.0

  • Added support for PHP 8.2.

1.3.1

  • Removed JSON module for PHP 7.4 and later.

1.3.0

  • Introduced php_remove_unused_modules variable:
    • Default is false.
    • If set to true, it removes PHP modules not listed in php variable.
  • Introduced php_remove_unused_versions variable:
    • Default is false.
    • If set to true, it removes PHP versions not listed in php variable.
  • Fixed issue with replacing certain characters.

1.2.0

  • Added support for PHP 8.1.

1.1.2

  • Fixed default PHP version setting.
  • Fixed Redis and Imagick extensions.

1.1.1

  • Updated README.
  • Fixed Ansible Lint errors.

1.1.0

  • Added support for installation on Ubuntu, tested on Focal.

1.0.0

  • Added support for installing different PHP versions on Debian Buster.

Installation

To install using ansible-galaxy:

$ ansible-galaxy install lukasic.php

To install using requirements.yml:

- src: lukasic.php

Requirements

This role requires the APT repository deb.sury.org provided by Ondrej Sury.

It is tested on Debian Buster and Ubuntu Focal, but it should work on other versions if the required packages are available.

Role Variables

Default PHP version:

php_default_version: "7.3"

List of PHP modules to install for all versions:

php_default_modules:
 - bcmath
 - bz2
 - curl
 - gd
 - readline
 - json
 - mysql
 - soap
 - opcache
 - xml
 - xmlrpc
 - zip

You can customize modules for specific PHP versions:

php56_default_modules: "{{ php_default_modules }}"
php70_default_modules: "{{ php_default_modules }}"
php71_default_modules: "{{ php_default_modules }}"
php72_default_modules: "{{ php_default_modules }}"
php73_default_modules: "{{ php_default_modules }}"
php74_default_modules: "{{ php_default_modules }}"
php80_default_modules: "{{ php_default_modules }}"
php81_default_modules: "{{ php_default_modules }}"

A special variable to control installed PHP versions and settings:

php: []

Dependencies

None.

Example Playbook

Example 1: Install PHP 5.6 and 7.3

- hosts: php
  roles:
     - lukasic.php
  vars:
    php:
      - version: php56
      - version: php73

Example 2: Install PHP 5.6, 7.3, 8.0 with extra modules and configure global settings.

- hosts: php
  roles:
     - lukasic.php
  vars:
    common_fpm_ini:
     - { "section": "PHP",     "key": "max_execution_time",             "value": "360"  }
     - { "section": "PHP",     "key": "post_max_size",                  "value": "64MB" }
     - { "section": "PHP",     "key": "upload_max_filesize",            "value": "64MB" }
     - { "section": "opcache", "key": "opcache.enable",                 "value": "1"    }
     - { "section": "opcache", "key": "opcache.memory_consumption",     "value": "512"  }
     - { "section": "opcache", "key": "opcache.max_accelerated_files",  "value": "500"  }
    php:
     - version: php56
       fpm_ini: "{{ common_fpm_ini }}"
       cli_ini:
        - section: "PHP"
          key: "memory_limit"
          value: "2048M"
     - version: php73
       modules_extra: ['pgsql', 'gd']
       fpm_ini: "{{ common_fpm_ini }}"
     - version: php80
       modules_extra: ['pgsql', 'gd']
       fpm_ini: "{{ common_fpm_ini }}"

License

WTFPL

Author Information

This role was created in 2020 by Lukáš Kasič.

Informazioni sul progetto

Debian/Ubuntu multi-php role

Installa
ansible-galaxy install lukasic.php
Licenza
Unknown
Download
33k
Proprietario