php-fpm: fix the path of the session files.

This commit is contained in:
Andrea Dell'Amico 2019-10-09 16:25:05 +02:00
parent 1ee45a1c54
commit ede935b45d
3 changed files with 11 additions and 9 deletions

View File

@ -68,7 +68,7 @@ phpfpm_default_extensions: ".php"
phpfpm_default_context: '/' phpfpm_default_context: '/'
phpfpm_default_session_handler: 'files' phpfpm_default_session_handler: 'files'
phpfpm_default_session_prefix: '/var/lib/php' phpfpm_default_session_prefix: '/var/lib/php'
phpfpm_session_prefix: '{{ phpfpm_default_session_prefix }}' phpfpm_default_session_dir: '{{ phpfpm_default_session_prefix }}/sessions'
phpfpm_default_define_custom_variables: False phpfpm_default_define_custom_variables: False
phpfpm_use_memcache_redundancy_sessions: False phpfpm_use_memcache_redundancy_sessions: False

View File

@ -2,7 +2,7 @@
# php as a standalone service # php as a standalone service
- name: Install the Ubuntu PHP PPA - name: Install the Ubuntu PHP PPA
apt_repository: repo={{ php_ppa }} state=present update_cache=yes apt_repository: repo={{ php_ppa }} state=present update_cache=yes
when: php_from_ppa when: php_from_ppa | bool
tags: [ 'php', 'php_ppa' ] tags: [ 'php', 'php_ppa' ]
- name: Remove the Ubuntu PHP PPA - name: Remove the Ubuntu PHP PPA
@ -37,28 +37,30 @@
- name: Activate the memcache sessions support and redundancy if needed - name: Activate the memcache sessions support and redundancy if needed
action: configfile path={{ phpfpm_base_dir }}/conf.d/20-memcache.ini key={{ item.prop }} value='{{ item.value }}' action: configfile path={{ phpfpm_base_dir }}/conf.d/20-memcache.ini key={{ item.prop }} value='{{ item.value }}'
when: phpfpm_use_memcache_redundancy_sessions when: phpfpm_use_memcache_redundancy_sessions | bool
with_items: '{{ memcache_session }}' with_items: '{{ memcache_session }}'
notify: Reload php-fpm notify: Reload php-fpm
tags: [ 'php', 'php_ini' ] tags: [ 'php', 'php_ini' ]
- name: remove php-fpm default pool - name: remove php-fpm default pool
file: dest={{ phpfpm_base_dir }}/pool.d/www.conf state=absent file: dest={{ phpfpm_base_dir }}/pool.d/www.conf state=absent
when: phpfpm_remove_default_pool when: phpfpm_remove_default_pool | bool
notify: Restart php-fpm notify: Restart php-fpm
tags: php tags: php
- name: Create the users under the php-fpm processes will run - name: Create the users under the php-fpm processes will run
user: name={{ item.user }} comment="{{ item.user }}" home=/dev/null createhome=no shell=/sbin/nologin user: name={{ item.user }} comment="{{ item.user }}" home=/dev/null createhome=no shell=/sbin/nologin
with_items: '{{ phpfpm_pools }}' with_items: '{{ phpfpm_pools }}'
when: phpfpm_create_users when: phpfpm_create_users | bool
notify: Restart php-fpm notify: Restart php-fpm
tags: [ 'php', 'fpm_pool' ] tags: [ 'php', 'fpm_pool' ]
- name: Create the directories where to store the sessions files. One for each pool - name: Create the directories where to store the sessions files. One for each pool
file: dest={{ phpfpm_session_prefix }}/{{ item.pool_name }} owner={{ item.user }} group=root mode=0750 state=directory file: dest={{ phpfpm_session_prefix }}/{{ item.pool_name }} owner={{ item.user }} group=root mode=0750 state=directory
with_items: '{{ phpfpm_pools }}' with_items: '{{ phpfpm_pools }}'
when: phpfpm_use_default_template when:
- phpfpm_session_prefix is defined
- phpfpm_use_default_template | bool
tags: [ 'php', 'fpm_pool' ] tags: [ 'php', 'fpm_pool' ]
- name: Create the directories where to store the log files - name: Create the directories where to store the log files
@ -77,13 +79,13 @@
- name: Install the php-fpm pools - name: Install the php-fpm pools
template: src=php-fpm-pool.conf.j2 dest={{ phpfpm_base_dir }}/pool.d/{{ item.pool_name }}.conf owner=root group=root mode=0444 template: src=php-fpm-pool.conf.j2 dest={{ phpfpm_base_dir }}/pool.d/{{ item.pool_name }}.conf owner=root group=root mode=0444
with_items: '{{ phpfpm_pools }}' with_items: '{{ phpfpm_pools }}'
when: phpfpm_use_default_template when: phpfpm_use_default_template | bool
notify: Restart php-fpm notify: Restart php-fpm
tags: [ 'php', 'fpm_conf', 'fpm_pool', 'fpm_pool_conf' ] tags: [ 'php', 'fpm_conf', 'fpm_pool', 'fpm_pool_conf' ]
- name: Ensure that the php-fpm service is started and enabled - name: Ensure that the php-fpm service is started and enabled
service: name=php{{ php_version }}-fpm state=started enabled=yes service: name=php{{ php_version }}-fpm state=started enabled=yes
when: phpfpm_service_enabled when: phpfpm_service_enabled | bool
tags: php tags: php
- name: Ensure that the php-fpm service is stopped and disabled - name: Ensure that the php-fpm service is stopped and disabled

View File

@ -284,7 +284,7 @@ php_value[session.save_handler] = '{{ item.session_save_handler | default('files
{% if phpfpm_session_prefix is defined %} {% if phpfpm_session_prefix is defined %}
php_value[session.save_path] = '{{ phpfpm_session_prefix }}/{{ item.pool_name }}' php_value[session.save_path] = '{{ phpfpm_session_prefix }}/{{ item.pool_name }}'
{% else %} {% else %}
php_value[session.save_path] = '/var/lib/php/www' php_value[session.save_path] = '{{ phpfpm_default_session_dir }}'
{% endif %} {% endif %}
{% if item.define_custom_variables is defined and item.define_custom_variables %} {% if item.define_custom_variables is defined and item.define_custom_variables %}
{% for php_var in phpfpm_php_variables %} {% for php_var in phpfpm_php_variables %}