mirror of
https://github.com/HanXHX/ansible-nginx.git
synced 2026-02-24 09:03:29 +07:00
Support many php versions (php7) + drop wheezy support
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
{% extends "_base.j2" %}
|
||||
{% extends "_php.j2" %}
|
||||
|
||||
{% block root %}
|
||||
root {{ nginx_nagios_root }};
|
||||
@@ -56,7 +56,7 @@
|
||||
fastcgi_param REMOTE_USER $remote_user;
|
||||
}
|
||||
location ~ \.php$ {
|
||||
fastcgi_pass php;
|
||||
fastcgi_pass {{ php_upstream }};
|
||||
fastcgi_index index.php;
|
||||
{% if nginx_version.stdout | version_compare('1.6.1', 'lt') %}
|
||||
include fastcgi_params;
|
||||
|
||||
@@ -1,4 +1,24 @@
|
||||
{% extends "_base.j2" %}
|
||||
|
||||
{% macro phpv(version) %}
|
||||
{% if version == 5 %}
|
||||
{{ nginx_upstream_php5 -}}
|
||||
{% elif version == 7 %}
|
||||
{{ nginx_upstream_php7 -}}
|
||||
{% else %}
|
||||
{# Hack... define another upstream #}
|
||||
{{ version -}}
|
||||
{% endif %}
|
||||
{%- endmacro -%}
|
||||
|
||||
{% if item.php_version is defined %}
|
||||
{% set php_upstream = phpv(item.php_version) %}
|
||||
{% elif nginx_php5 %}
|
||||
{% set php_upstream = phpv(5) %}
|
||||
{% elif nginx_php7 %}
|
||||
{% set php_upstream = phpv(7) %}
|
||||
{% endif %}
|
||||
|
||||
{% block template_index %}
|
||||
index {{ item.index | default('index.html index.htm index.php') }};
|
||||
{% endblock %}
|
||||
@@ -9,7 +29,7 @@
|
||||
|
||||
{% block template_upstream_location %}
|
||||
location ~ \.php$ {
|
||||
fastcgi_pass php;
|
||||
fastcgi_pass {{ php_upstream }};
|
||||
fastcgi_index index.php;
|
||||
{% if item.upstream_params is defined and item.upstream_params is iterable %}
|
||||
{% for param in item.upstream_params %}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
{% block template_upstream_location %}
|
||||
location = /index.php {
|
||||
fastcgi_pass php;
|
||||
fastcgi_pass {{ php_upstream }};
|
||||
fastcgi_index index.php;
|
||||
{% if item.upstream_params is defined and item.upstream_params is iterable %}
|
||||
{% for param in item.upstream_params %}
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
# {{ ansible_managed }}
|
||||
#
|
||||
|
||||
upstream php {
|
||||
{% for item in nginx_php_sockets %}
|
||||
{% if nginx_php5 %}
|
||||
upstream {{ nginx_upstream_php5 }} {
|
||||
{% for item in nginx_php5_sockets %}
|
||||
{% if item.unix_socket is defined %}
|
||||
server unix:{{ item.unix_socket }} weight={{ item.weight | default('1') }};
|
||||
{% else %}
|
||||
@@ -12,4 +13,18 @@ upstream php {
|
||||
{% endfor %}
|
||||
}
|
||||
|
||||
{% endif %}
|
||||
{% if nginx_php7 %}
|
||||
upstream {{ nginx_upstream_php7 }} {
|
||||
{% for item in nginx_php7_sockets %}
|
||||
{% if item.unix_socket is defined %}
|
||||
server unix:{{ item.unix_socket }} weight={{ item.weight | default('1') }};
|
||||
{% else %}
|
||||
server {{ item.host }}:{{ item.port }} weight={{ item.weight | default('1') }} max_fails={{ item.max_fails | default('5') }} fail_timeout={{ item.fail_timeout | default('10s') }};
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
}
|
||||
|
||||
{% endif %}
|
||||
|
||||
# vim:filetype=nginx
|
||||
|
||||
Reference in New Issue
Block a user