Manages PHP minor versions

pull/22/head
Emilien Mantel 2016-08-11 11:30:26 +02:00
parent a9ad41b40f
commit 88c6c5a043
9 changed files with 30 additions and 28 deletions

View File

@ -31,11 +31,11 @@ nginx_helper_dir: '{{ nginx_etc_dir}}/helper'
# #
# PHP # PHP
nginx_php5: false nginx_php56: false
nginx_php7: false nginx_php70: false
nginx_php5_sockets: nginx_php56_sockets:
- unix_socket: "/run/php5-fpm.sock" - unix_socket: "/run/php5-fpm.sock"
nginx_php7_sockets: nginx_php70_sockets:
- unix_socket: "/run/php/php7.0-fpm.sock" - unix_socket: "/run/php/php7.0-fpm.sock"
nginx_upstreams: [] nginx_upstreams: []

View File

@ -1,8 +1,8 @@
PHP PHP
=== ===
- `nginx_php5` and `nginx_php7`: boolean if you need to preconfigure PHP (default: false) - `nginx_php56` and `nginx_php70`: boolean if you need to preconfigure PHP (default: false)
- `nginx_php_sockets`: list of sockets (see bellow) - `nginx_php##_sockets`: list of sockets (see bellow)
You should see [Nginx upstream module doc](http://nginx.org/en/docs/http/ngx_http_upstream_module.html). You should see [Nginx upstream module doc](http://nginx.org/en/docs/http/ngx_http_upstream_module.html).

View File

@ -4,7 +4,7 @@
template: > template: >
src=etc/nginx/upstream/php.conf.j2 src=etc/nginx/upstream/php.conf.j2
dest="{{ nginx_etc_dir }}/conf.d/php.conf" dest="{{ nginx_etc_dir }}/conf.d/php.conf"
when: nginx_php5 or nginx_php7 when: nginx_php56 or nginx_php70
notify: reload nginx notify: reload nginx
- name: TEMPLATE | Deploy other upstreams - name: TEMPLATE | Deploy other upstreams

View File

@ -1,10 +1,10 @@
{% extends "_base.j2" %} {% extends "_base.j2" %}
{% macro phpv(version) %} {% macro phpv(version) %}
{% if version == 5 %} {% if version == 56 %}
{{ nginx_upstream_php5 -}} {{ nginx_upstream_php56 -}}
{% elif version == 7 %} {% elif version == 70 %}
{{ nginx_upstream_php7 -}} {{ nginx_upstream_php70 -}}
{% else %} {% else %}
{# Hack... define another upstream #} {# Hack... define another upstream #}
{{ version -}} {{ version -}}
@ -13,10 +13,10 @@
{% if item.php_version is defined %} {% if item.php_version is defined %}
{% set php_upstream = phpv(item.php_version) %} {% set php_upstream = phpv(item.php_version) %}
{% elif nginx_php5 %} {% elif nginx_php56 %}
{% set php_upstream = phpv(5) %} {% set php_upstream = phpv(56) %}
{% elif nginx_php7 %} {% elif nginx_php70 %}
{% set php_upstream = phpv(7) %} {% set php_upstream = phpv(70) %}
{% endif %} {% endif %}
{% block template_index %} {% block template_index %}

View File

@ -2,9 +2,9 @@
# {{ ansible_managed }} # {{ ansible_managed }}
# #
{% if nginx_php5 %} {% if nginx_php56 %}
upstream {{ nginx_upstream_php5 }} { upstream {{ nginx_upstream_php56 }} {
{% for item in nginx_php5_sockets %} {% for item in nginx_php56_sockets %}
{% if item.unix_socket is defined %} {% if item.unix_socket is defined %}
server unix:{{ item.unix_socket }} weight={{ item.weight | default('1') }}; server unix:{{ item.unix_socket }} weight={{ item.weight | default('1') }};
{% else %} {% else %}
@ -14,9 +14,9 @@ upstream {{ nginx_upstream_php5 }} {
} }
{% endif %} {% endif %}
{% if nginx_php7 %} {% if nginx_php70 %}
upstream {{ nginx_upstream_php7 }} { upstream {{ nginx_upstream_php70 }} {
{% for item in nginx_php7_sockets %} {% for item in nginx_php70_sockets %}
{% if item.unix_socket is defined %} {% if item.unix_socket is defined %}
server unix:{{ item.unix_socket }} weight={{ item.weight | default('1') }}; server unix:{{ item.unix_socket }} weight={{ item.weight | default('1') }};
{% else %} {% else %}

View File

@ -21,7 +21,9 @@
- fcgiwrap - fcgiwrap
- nghttp2 - nghttp2
- php5-fpm - php5-fpm
- php5-sqlite
- php7.0-fpm - php7.0-fpm
- php7.0-sqlite3
- strace - strace
- vim - vim

View File

@ -4,8 +4,8 @@
set_fact: set_fact:
nginx_pkgng_package: 'nginx-devel' nginx_pkgng_package: 'nginx-devel'
nginx_user: 'www' nginx_user: 'www'
nginx_php7: false nginx_php70: false
nginx_php5_sockets: nginx_php56_sockets:
- host: '127.0.0.1' - host: '127.0.0.1'
port: 9000 port: 9000

View File

@ -17,8 +17,8 @@
nginx_worker_processes: 1 # Ansible+FreeBSD can't detect CPU number nginx_worker_processes: 1 # Ansible+FreeBSD can't detect CPU number
nginx_apt_package: 'nginx-extras' nginx_apt_package: 'nginx-extras'
nginx_backports: true nginx_backports: true
nginx_php5: true nginx_php56: true
nginx_php7: true nginx_php70: true
nginx_upstreams: nginx_upstreams:
- name: 'test' - name: 'test'
servers: servers:
@ -147,7 +147,7 @@
'/': '/':
- 'alias /var/tmp;' - 'alias /var/tmp;'
- name: 'test-php.local' - name: 'test-php.local'
php_version: 7 php_version: 70
upstream_params: upstream_params:
- 'fastcgi_param FOO bar;' - 'fastcgi_param FOO bar;'
redirect_from: redirect_from:

View File

@ -33,5 +33,5 @@ nginx_templates_no_dir:
- '_owncloud' - '_owncloud'
- '_proxy' - '_proxy'
nginx_upstream_php5: 'php5' nginx_upstream_php56: 'php56'
nginx_upstream_php7: 'php7' nginx_upstream_php70: 'php70'