ansible-nginx/templates/etc/nginx/sites-available/_php.j2

46 lines
1.1 KiB
Django/Jinja

{% extends "_base.j2" %}
{% macro phpv(version) %}
{% if version == 56 or version == "5.6" %}
{{ nginx_upstream_php56 -}}
{% elif version == 70 or version == "7.0" %}
{{ nginx_upstream_php70 -}}
{% else %}
{# Hack... define another upstream #}
{{ version -}}
{% endif %}
{%- endmacro -%}
{% if item.php_version is defined %}
{% set php_upstream = phpv(item.php_version) %}
{% elif nginx_php56 %}
{% set php_upstream = phpv(56) %}
{% elif nginx_php70 %}
{% set php_upstream = phpv(70) %}
{% endif %}
{% block template_index %}
index {{ item.index | default('index.html index.htm index.php') }};
{% endblock %}
{% block template_try_files %}
try_files {{ override_try_files | default('$uri $uri/ /index.php') }};
{% endblock %}
{% block template_upstream_location %}
location ~ \.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 %}
{{ param }}
{% endfor %}
{% endif %}
{% if nginx_version.stdout | version_compare('1.6.1', 'lt') %}
include fastcgi_params;
{% else %}
include fastcgi.conf;
{% endif %}
}
{% endblock %}