net2grid.php

Ansible Role: PHP

Build Status

This role installs PHP on servers running RedHat/CentOS or Debian/Ubuntu.

Requirements

If you have an older version of Ubuntu or RHEL with outdated PHP, you will need to use a repository or PPA that has a newer PHP version since this role only works with versions of PHP that are currently supported.

Role Variables

Here are the available variables and their default values (see defaults/main.yml):

  • php_packages: []

    • List of PHP packages to install (defaults are OS-specific). You might want to install common packages like php, php-cli, php-devel, and php-pdo, and you can add others like php-gd for image handling.
  • php_packages_extra: []

    • Additional PHP packages to install without changing the default list.
  • php_enable_webserver: true

    • Leave this as is if using PHP with a web server (like Apache or Nginx). Set to false if you’re using PHP for server-side tasks or apps that don't need a web server.
  • php_webserver_daemon: "httpd"

    • Default HTTP server daemon (for Apache). Change this if using a different server (like nginx).
  • php_enablerepo: ""

    • For RedHat/CentOS only. List any extra repositories here to use their PHP versions (e.g. remi-php70,epel).
  • php_packages_state: "present"

    • Set to "latest" if you want to upgrade to the latest PHP version when using additional repositories.
  • php_install_recommends: true

    • For Debian/Ubuntu only. Set to false if you do not want to install recommended packages.
  • php_executable: "php"

    • The command used to run PHP from the command line. Change it only if necessary.

PHP-FPM

PHP-FPM (FastCGI Process Manager) helps manage PHP applications effectively. To use PHP-FPM, set:

  • php_enable_php_fpm: false (change to true if using PHP-FPM).

You can configure useful settings for FPM, like:

  • php_fpm_listen: "127.0.0.1:9000"
  • php_fpm_pm_max_children: 50
  • php_fpm_pm_start_servers: 5
  • php_fpm_pm_min_spare_servers: 5
  • php_fpm_pm_max_spare_servers: 5

php.ini Settings

  • php_use_managed_ini: true
    • By default, this role manages the php.ini settings. Set it to false if you want to manage your own.

Various default settings include:

  • php_memory_limit: "256M"
  • php_max_execution_time: "60"
  • php_post_max_size: "32M"
  • php_display_errors: "Off"

OpCache Variables

OpCache improves PHP performance. Settings take effect if PHP version is 5.5 or above:

  • php_opcache_enable: "1"
  • php_opcache_memory_consumption: "96"
  • php_opcache_max_accelerated_files: "4096"

APCu Variables

APCu caching can be enabled with:

  • php_enable_apc: true
  • php_apc_shm_size: "96M"

Source Installation

If you want a specific PHP version, you can compile it from source:

  • php_install_from_source: false (set to true to compile).
  • php_source_version: "master" (the version you want).

Dependencies

None.

Example Playbook

- hosts: webservers
  vars_files:
    - vars/main.yml
  roles:
    - { role: geerlingguy.php }

In vars/main.yml:

php_memory_limit: "128M"
php_max_execution_time: "90"
php_upload_max_filesize: "256M"
php_packages:
  - php
  - php-cli
  - php-common
  - php-devel
  - php-gd
  - php-mbstring
  - php-pdo
  - php-pecl-apcu
  - php-xml
  ...

License

MIT / BSD

Author Information

This role was created in 2014 by Jeff Geerling, author of Ansible for DevOps.

Informazioni sul progetto

PHP for RedHat/CentOS/Fedora/Debian/Ubuntu.

Installa
ansible-galaxy install net2grid.php
Licenza
mit
Download
274
Proprietario
We empower energy retailers to help consumers become energy efficient by unlocking value from Smart Meter data