apham0001.php

Ansible Role: PHP

Build Status

This Ansible role installs PHP on RedHat/CentOS and Debian/Ubuntu servers.

Requirements

If you're using an older version of Ubuntu or RHEL with an outdated PHP version, you will need to have a repository or PPA that provides a maintained PHP version. This role only works with PHP versions that are supported by the PHP community.

Role Variables

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

  • php_packages: [] A list of PHP packages to install (OS-specific by default). Common packages include php, php-cli, php-devel, and php-pdo. Add any other packages you want, like php-gd for image manipulation or php-ldap for LDAP authentication.

Note: On Debian/Ubuntu, you also need to install libapache2-mod-fastcgi for cgi/PHP-FPM, or libapache2-mod-php7.0 (depending on your PHP version) to use mod_php with Apache.

  • php_packages_extra: [] A list of additional PHP packages to install without replacing the default list.

  • php_enable_webserver: true Set to true if PHP is used with a web server (e.g., Apache or Nginx). If you're using PHP server-side or for a small app, set this to false.

  • php_webserver_daemon: "httpd" The default HTTP server daemon: httpd for RedHat/CentOS, and apache2 for Debian/Ubuntu. Change this if you're using another web server, like nginx.

  • php_enablerepo: "" For RedHat/CentOS systems, list any additional repositories here (like remi-php70,epel) to easily install newer PHP versions from them.

  • php_default_version_debian: "7.0" The default PHP version for Debian/Ubuntu. Set this to "7.2" for Ubuntu 18.04 as it doesn't have PHP 7.0 in default packages.

If you want to easily switch PHP versions or use a version not available in system packages, consider using the geerlingguy.php-versions role.

  • php_packages_state: "present" This variable is set to "present" by default. You can change it to "latest" to upgrade to the latest version without needing to uninstall existing PHP packages first.

  • php_install_recommends: true For Debian/Ubuntu only. Indicates whether to install recommended packages. Set to no if you don’t want certain recommended packages from a PPA.

  • php_executable: "php" The command to run PHP from the command line. Change this only if you need a different PHP executable.

PHP-FPM

PHP-FPM (FastCGI Process Manager) is a tool for scaling PHP applications. If using PHP-FPM instead of Apache’s mod_php, set the following:

  • php_enable_php_fpm: false Set to true if using PHP-FPM.

You can configure Apache to work with PHP-FPM using the geerlingguy.apache-php-fpm role.

  • php_fpm_pools: Configuration for PHP-FPM pools, such as user, group, listening socket, and process management settings.

php.ini settings

  • php_use_managed_ini: true Manage php.ini automatically. Set to false if you want to manage your own php.ini file.

OpCache optimizes PHP performance. Set the following variables for versions 5.5 or greater:

  • php_opcache_zend_extension: "opcache.so"
  • php_opcache_enable: "1"
  • php_opcache_memory_consumption: "96"
  • php_opcache_max_accelerated_files: "4096"

Make sure you have enough memory allocated in OpCache to optimize performance.

  • php_enable_apc: true Enable APCu for caching. If set to false, related settings won't have an effect.

Installing from Source

If you need a specific or latest version of PHP, you can install it from source:

  • php_install_from_source: false Set to true to install PHP from source.

  • php_source_version: "master"

  • Set various parameters for cloning and compiling the source.

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 by Jeff Geerling in 2014.

Informazioni sul progetto

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

Installa
ansible-galaxy install apham0001.php
Licenza
mit
Download
288
Proprietario