chusiang.php7

Rol de Ansible: PHP 7 (PHP-FPM)

Estado de Construcción Liberación Estrella Fork Licencia Ansible Galaxy Docker Hub

Un rol de Ansible para desplegar PHP 7 (php-fpm) para Nginx. (derivado de itcraftsmanpl.php7)

  • Versión actual de PHP7:

    • Debian y Ubuntu: 7.1.30
    • CentOS: 7.1.30
  • Distribuciones de Linux soportadas:

    1. Ubuntu 18.04 (biónico)
    2. Ubuntu 16.04 (xenial)
    3. Debian 8 (jessie)
    4. Debian 9 (stretch)
    5. CentOS 6
    6. CentOS 7

Requisitos

Ninguno.

Variables del Rol

Las variables disponibles se enumeran a continuación, junto con sus valores predeterminados (ver defaults/main.yml):

#######
# Todas #
#######

# solo para depuración.
debug_mode: false

# allow_url_fopen
#   Valor predeterminado: Activado
php_allow_url_fopen: "Off"

php_disable_functions: "exec,passthru,shell_exec,system,proc_open,popen"
php_display_errors: "Off"
php_error_reporting: "E_ALL & ~E_DEPRECATED & ~E_STRICT"

# deshabilitar la exposición de la versión de php.
#   Valor predeterminado: Activado
php_expose_php: 'Off'

php_memory_limit: "1024M"
php_opcache_enable: 1
php_opcache_revalidate_freq: 0
php_post_max_size: "20M"
php_serialize_precision: 17
php_session_cookie_httponly: 1
php_session_use_strict_mode: 1
php_soap_wsdl_cache_dir: '/php/cache/wsdl'
php_timezone: "Asia/Taipei"
php_upload_max_filesize: "20M"
php_upload_tmp_dir: "/php/cache/upload_tmp"

# Nota: necesitamos usar 'www-data' en Debian 8.
php_owner: 'www-data'
php_group: 'www-data'

###################
# Debian y Ubuntu #
###################

debian_php7_apt_repo: "http://packages.dotdeb.org"
debian_php7_apt_key: "https://www.dotdeb.org/dotdeb.gpg"
ubuntu_php7_ppa_repo: "ppa:ondrej/php"

# Un interruptor para habilitar o deshabilitar el repositorio de terceros.
#
#  true: usar el repositorio oficial.
#  false: usar el repositorio de terceros.
apt_php_third_party_repo: true

apt_php_version: "7.1"

apt_php_packages:
  - php{{ apt_php_version }}
  - php{{ apt_php_version }}-cgi
  - php{{ apt_php_version }}-cli
  - php{{ apt_php_version }}-common
  - php{{ apt_php_version }}-curl
  - php{{ apt_php_version }}-fpm
  - php{{ apt_php_version }}-gd
  - php{{ apt_php_version }}-intl
  - php{{ apt_php_version }}-json
  - php{{ apt_php_version }}-mysql
  #- php{{ apt_php_version }}-pear

##########
# CentOS #
##########

yum_php_version: "71u"

yum_php_packages:
  - php{{ yum_php_version }}-cli
  - php{{ yum_php_version }}-common
  - php{{ yum_php_version }}-fpm
  - php{{ yum_php_version }}-fpm-nginx
  - php{{ yum_php_version }}-json
  - php{{ yum_php_version }}-mysqlnd
  - php{{ yum_php_version }}-opcache
  - php{{ yum_php_version }}-pdo
 #- php{{ yum_php_version }}-mbstring
 #- php{{ yum_php_version }}-pear

# PHP-FPM FastCGI.
centos_php_fastcgi_listen: "/run/php-fpm/www.sock"
centos_nginx_fastcgi_server: "unix:{{ centos_php_fastcgi_listen }}"

Nota

  1. Si ves un mensaje de error, es posible que necesites modificar php_owner y php_group de nginx a www-data.

    • Navegador:

      Ocurrió un error.

    • error.log:

      connect() to unix:/var/run/php/php7.0-fpm.sock falló (13: Permiso denegado) al conectar con upstream ...

  2. La /target/path/ del socket, y los archivos de configuración son diferentes en Ubuntu y CentOS. ¡Ten cuidado con la configuración de tu Nginx!

    • Debian y Ubuntu:

      • Configuración:
        • /etc/php/7.0/fpm/php.ini
        • /etc/php/7.0/cli/php.ini
      • Socket: /var/run/php/php7.0-fpm.sock
    • CentOS:

      • Configuración:
        • /etc/php-fpm.d/www.conf
        • /etc/php.ini
      • Socket: /run/php-fpm/www.sock
  3. Agregamos la variable apt_php_third_party_repo para habilitar o deshabilitar el repositorio de terceros (después de v1.3.6).

    • true: usar el repositorio de terceros.
    • false: usar el repositorio oficial de debian / ubuntu.

Dependencias

Ninguna.

Si necesitas configurar nginx, puedes usar el rol williamyeh.nginx.

Ejemplo de Playbook

- hosts: servidores-web
  roles:
    - { role: chusiang.php7 }

Contenedores Docker

Este repositorio contiene Ansible Dockerizado, publicado en el público Docker Hub a través de un mecanismo de construcción automática.

Docker Hub: chusiang/php7

Imágenes

  • chusiang/php7:ubuntu-16.04 (última)
  • chusiang/php7:ubuntu-14.04
  • chusiang/php7:centos6 (fin de soporte)

Uso

$ docker run -it -v /src:/data chusiang/php7:ubuntu14.04 bash
[root@a68e807eec8f tmp]# php -v
PHP 7.0.7 (cli) (compilado: 31 de mayo de 2016 11:36:12) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    con Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, por Zend Technologies

Historial

  • 2019/05/04 Dejó de soportar Ubuntu 14.04. #24

Licencia

Licencia MIT (2015 - 2018). Ver el archivo LICENSE para detalles.

Información del Autor

  1. itcraftsmanpl (Arkadiusz Kondas)
  2. chusiang (Chu-Siang Lai)
Acerca del proyecto

Deploy PHP 7 (php-fpm) for nginx on Ubuntu, Debian and CentOS. (forked from itcraftsmanpl.php7)

Instalar
ansible-galaxy install chusiang.php7
Licencia
mit
Descargas
2.3k
Propietario
A system engineer, like @DevOpsTW, @ansible-tw, @vim-tw, docker and @linux-taiwan. Hope one day can build a "🦄 Unicorn company" like《The Phoenix Project》.