diff --git a/roles/php7_fpm/defaults/main.yml b/roles/php7_fpm/defaults/main.yml index 8ba10bf3a76178bbfc70e2437f1fba285ad67e96..5304aa6c8ed93c2b03b7c30faac90d7bda1848c5 100644 --- a/roles/php7_fpm/defaults/main.yml +++ b/roles/php7_fpm/defaults/main.yml @@ -1,15 +1,28 @@ --- - -php_memory: "512M" +# +# php_www_conf_file +# php_pm_max_children: "7" php_pm_start_servers: "2" -php_pm_min_spare_servers: "1" -php_pm_max_spare_servers: "3" -opcache_max_accelerated_files: "10000" -opcache_interned_strings_buffer: "16" -opcache_save_comments: "1" -opcache_revalidate_freq: "60" +php_pm_min_spare_servers: "1" +php_pm_max_spare_servers: "3" +# +# composer_version: 2.3.8 composer_sum: "c6ab768ad3239c4d4cc4f39f8ff7462925e088cd441e5bdb749fbf6efe049769" + +# +# php ini defaults +# +opcache_interned_strings_buffer: "16" +opcache_max_accelerated_files: "10000" +opcache_revalidate_freq: "60" +opcache_memory_consumption: 128 +opcache_save_comments: "1" +php_max_execution_time: "60" +php_memory: "512M" +php_upload_max_filesize: "2M" +php_post_max_size: "8M" upload_max_filesize: "2M" -opcache_memory_consumption: 128 \ No newline at end of file + + diff --git a/roles/php7_fpm/readme.md b/roles/php7_fpm/readme.md index 56d19086a58b6fd69031145e194d26455ce0e3da..ddbb4f103c981ca9f066d67d1e43cfa232bf9ebe 100644 --- a/roles/php7_fpm/readme.md +++ b/roles/php7_fpm/readme.md @@ -1,11 +1,33 @@ -You may adjust php7-fpm configuration by using variables : -Example -```yml -php_memory: 1536M +Compatible with php 8.1 + +* Install php packages +* Monit php fpm +* Install composer +* Install start, and monitor redis +* Adjust fpm configuration by using variables, works also for php fpm 8.1 + + +Update **php_www_conf_file**: "/etc/php/{{ php_version }}/fpm/pool.d/www.conf" + +Variables php_pm_max_children: "25" php_pm_start_servers: "15" php_pm_min_spare_servers: "10" php_pm_max_spare_servers: "20" -``` \ No newline at end of file + +Update /etc/php/{{ php_version }}/fpm/php.ini + +Default values + +opcache_interned_strings_buffer: "16" +opcache_max_accelerated_files: "10000" +opcache_revalidate_freq: "60" +opcache_save_comments: "1" +php_max_execution_time: "60" +php_memory: "512M" +php_upload_max_filesize: "2M" +php_post_max_size: "8M" + + diff --git a/roles/php7_fpm/tasks/composer.yml b/roles/php7_fpm/tasks/composer.yml index 6d59bbefaef1466a9d52c9452df29eaf8421e7f3..2154aec05433f2e0968f84e8d11ac4c429a2478f 100644 --- a/roles/php7_fpm/tasks/composer.yml +++ b/roles/php7_fpm/tasks/composer.yml @@ -3,16 +3,17 @@ # thanks to https://www.devopsaurus.com/install-composer-with-ansible/ # - name: Download and install Composer - get_url: + ansible.builtin.get_url: checksum: "sha256:{{ composer_sum }}" dest: /usr/src/ + mode: u=rw,g=r,o=r url: https://getcomposer.org/download/{{ composer_version }}/composer.phar - name: Add Composer to global path - copy: + ansible.builtin.copy: dest: /usr/local/bin/composer group: root mode: '0755' owner: root src: /usr/src/composer.phar - remote_src: yes + remote_src: true diff --git a/roles/php7_fpm/tasks/configure_fpm.yml b/roles/php7_fpm/tasks/configure_fpm.yml index e43076339fb44e697e4dc566b300bfcc677ee7c1..1966e8afc7096595d05b963acdcb0afaf6238c52 100644 --- a/roles/php7_fpm/tasks/configure_fpm.yml +++ b/roles/php7_fpm/tasks/configure_fpm.yml @@ -1,112 +1,71 @@ --- - - name: "Memory limit from 128M to {{ php_memory }} for PHP{{ php_version }}" - lineinfile: - line: "memory_limit = {{ php_memory }}" - regexp: "^memory_limit" - path: "{{ php_ini_file }}" - state: present - notify: reload php-fpm php7_fpm - tags: - - confphpfpm +- name: "Pm.max_children {{ php_pm_max_children }}" + ansible.builtin.lineinfile: + line: "pm.max_children = {{ php_pm_max_children }}" + regexp: "^pm\\.max_children" + path: "{{ php_www_conf_file }}" + state: present + notify: reload php-fpm php7_fpm + tags: + - confphpfpm - - name: "Memory consumption from 128M to {{ opcache_memory_consumption }} for PHP{{ php_version }}" - lineinfile: - line: "opcache.memory_consumption = {{ opcache_memory_consumption }}" - regexp: "^opcache.memory_consumption" - path: "{{ php_ini_file }}" - state: present - notify: reload php-fpm php7_fpm - tags: - - confphpfpm +- name: "Max pm.start_servers {{ php_pm_start_servers }}" + ansible.builtin.lineinfile: + line: "pm.start_servers = {{ php_pm_start_servers }}" + regexp: "^pm\\.start_servers" + path: "{{ php_www_conf_file }}" + state: present + notify: reload php-fpm php7_fpm + tags: + - confphpfpm - - name: "opcache.save_comments to {{ opcache_save_comments }} for PHP{{ php_version }}" - lineinfile: - line: "opcache.save_comments = {{ opcache_save_comments }}" - regexp: "^opcache.save_comments" - path: "{{ php_ini_file }}" - state: present - notify: reload php-fpm php7_fpm - tags: - - confphpfpm - - - name: "opcache.revalidate_freq to {{ opcache_revalidate_freq }} for PHP{{ php_version }}" - lineinfile: - line: "opcache.revalidate_freq = {{ opcache_revalidate_freq }}" - regexp: "^opcache.revalidate_freq" - path: "{{ php_ini_file }}" - state: present - notify: reload php-fpm php7_fpm - tags: - - confphpfpm +- name: "Memory consumption from 128M to {{ opcache_memory_consumption }} for PHP{{ php_version }}" + lineinfile: + line: "opcache.memory_consumption = {{ opcache_memory_consumption }}" + regexp: "^opcache.memory_consumption" + path: "{{ php_ini_file }}" + state: present + notify: reload php-fpm php7_fpm + tags: + - confphpfpm - - name: "opcache.max_accelerated_files to {{ opcache_max_accelerated_files }} for PHP{{ php_version }}" - lineinfile: - line: "opcache.max_accelerated_files = {{ opcache_max_accelerated_files }}" - regexp: "^opcache.max_accelerated_files" - path: "{{ php_ini_file }}" - state: present - notify: reload php-fpm php7_fpm - tags: - - confphpfpm +- name: "opcache.save_comments to {{ opcache_save_comments }} for PHP{{ php_version }}" + lineinfile: + line: "opcache.save_comments = {{ opcache_save_comments }}" + regexp: "^opcache.save_comments" + path: "{{ php_ini_file }}" + state: present + notify: reload php-fpm php7_fpm + tags: + - confphpfpm + +- name: "opcache.revalidate_freq to {{ opcache_revalidate_freq }} for PHP{{ php_version }}" + lineinfile: + line: "opcache.revalidate_freq = {{ opcache_revalidate_freq }}" + regexp: "^opcache.revalidate_freq" + path: "{{ php_ini_file }}" + state: present + notify: reload php-fpm php7_fpm + tags: + - confphpfpm - - name: "opcache.interned_strings_buffer to {{ opcache_interned_strings_buffer }} for PHP{{ php_version }}" - lineinfile: - line: "opcache.interned_strings_buffer = {{ opcache_interned_strings_buffer }}" - regexp: "^opcache.max_accelerated_files" - path: "{{ php_ini_file }}" - state: present - notify: reload php-fpm php7_fpm - tags: - - confphpfpm +- name: "Max pm.min_spare_servers {{ php_pm_min_spare_servers }}" + ansible.builtin.lineinfile: + line: "pm.min_spare_servers = {{ php_pm_min_spare_servers }}" + regexp: "^pm\\.min_spare_servers" + path: "{{ php_www_conf_file }}" + state: present + notify: reload php-fpm php7_fpm + tags: + - confphpfpm - - name: "pm.max_children {{ php_pm_max_children }} for PHP{{ php_version }}" - lineinfile: - line: "pm.max_children = {{ php_pm_max_children }}" - regexp: "^pm\\.max_children" - path: "{{ php_www_conf_file }}" - state: present - notify: reload php-fpm php7_fpm - tags: - - confphpfpm - - - name: "max pm.start_servers {{ php_pm_start_servers }} for PHP{{ php_version }}" - lineinfile: - line: "pm.start_servers = {{ php_pm_start_servers }}" - regexp: "^pm\\.start_servers" - path: "{{ php_www_conf_file }}" - state: present - notify: reload php-fpm php7_fpm - tags: - - confphpfpm - - - name: "max pm.min_spare_servers {{ php_pm_min_spare_servers }} for PHP{{ php_version }}" - lineinfile: - line: "pm.min_spare_servers = {{ php_pm_min_spare_servers }}" - regexp: "^pm\\.min_spare_servers" - path: "{{ php_www_conf_file }}" - state: present - notify: reload php-fpm php7_fpm - tags: - - confphpfpm - - - name: "max pm.max_spare_servers {{ php_pm_max_spare_servers }} for PHP{{ php_version }}" - lineinfile: - line: "pm.max_spare_servers = {{ php_pm_max_spare_servers }}" - regexp: "^pm\\.max_spare_servers" - path: "{{ php_www_conf_file }}" - state: present - notify: reload php-fpm php7_fpm - tags: - - confphpfpm - - - - name: "upload_max_filesize limit from 2M to {{ php_upload_max_filesize }} for PHP{{ php_version }}" - lineinfile: - line: "upload_max_filesize = {{ php_upload_max_filesize }}" - regexp: "^upload_max_filesize" - path: "{{ php_ini_file }}" - state: present - notify: reload php-fpm php7_fpm - tags: - - confphpfpm +- name: "Max pm.max_spare_servers {{ php_pm_max_spare_servers }}" + ansible.builtin.lineinfile: + line: "pm.max_spare_servers = {{ php_pm_max_spare_servers }}" + regexp: "^pm\\.max_spare_servers" + path: "{{ php_www_conf_file }}" + state: present + notify: reload php-fpm php7_fpm + tags: + - confphpfpm diff --git a/roles/php7_fpm/tasks/configure_fpm_ini.yml b/roles/php7_fpm/tasks/configure_fpm_ini.yml new file mode 100644 index 0000000000000000000000000000000000000000..17bc0da148d28769bd1dd25b999b06af016f37bb --- /dev/null +++ b/roles/php7_fpm/tasks/configure_fpm_ini.yml @@ -0,0 +1,111 @@ +--- + +- name: "Max_execution_time from 30 to {{ php_max_execution_time }}" + ansible.builtin.lineinfile: + line: "max_execution_time = {{ php_max_execution_time }}" + regexp: "^max_execution_time" + path: "{{ php_ini_file }}" + state: present + notify: reload php-fpm php7_fpm + tags: + - confphpfpm + +- name: "Memory limit from 128M to {{ php_memory }}" + ansible.builtin.lineinfile: + line: "memory_limit = {{ php_memory }}" + regexp: "^memory_limit" + path: "{{ php_ini_file }}" + state: present + notify: reload php-fpm php7_fpm + tags: + - confphpfpm + +- name: "Opcache.save_comments to {{ opcache_save_comments }}" + ansible.builtin.lineinfile: + line: "opcache.save_comments = {{ opcache_save_comments }}" + regexp: "^opcache.save_comments" + path: "{{ php_ini_file }}" + state: present + notify: reload php-fpm php7_fpm + tags: + - confphpfpm + +- name: "Opcache.revalidate_freq to {{ opcache_revalidate_freq }}" + ansible.builtin.lineinfile: + line: "opcache.revalidate_freq = {{ opcache_revalidate_freq }}" + regexp: "^opcache.revalidate_freq" + path: "{{ php_ini_file }}" + state: present + notify: reload php-fpm php7_fpm + tags: + - confphpfpm + +- name: "Opcache.max_accelerated_files to {{ opcache_max_accelerated_files }}" + ansible.builtin.lineinfile: + line: "opcache.max_accelerated_files = {{ opcache_max_accelerated_files }}" + regexp: "^opcache.max_accelerated_files" + path: "{{ php_ini_file }}" + state: present + notify: reload php-fpm php7_fpm + tags: + - confphpfpm + +- name: "Opcache.interned_strings_buffer to {{ opcache_interned_strings_buffer }}" + ansible.builtin.lineinfile: + line: "opcache.interned_strings_buffer = {{ opcache_interned_strings_buffer }}" + regexp: "^opcache.interned_strings_buffer" + path: "{{ php_ini_file }}" + state: present + notify: reload php-fpm php7_fpm + tags: + - confphpfpm + +- name: "Upload_max_filesize limit from 2M to {{ php_upload_max_filesize }}" + ansible.builtin.lineinfile: + line: "upload_max_filesize = {{ php_upload_max_filesize }}" + regexp: "^upload_max_filesize" + path: "{{ php_ini_file }}" + state: present + notify: reload php-fpm php7_fpm + tags: + - confphpfpm + +- name: "Update post_max_size limit from 8M to {{ php_post_max_size }}" + ansible.builtin.lineinfile: + line: "post_max_size = {{ php_post_max_size }}" + regexp: "^post_max_size" + path: "{{ php_ini_file }}" + state: present + notify: reload php-fpm php7_fpm + tags: + - confphpfpm + +- name: "OP Cache for PHP{{ php_version }}" + ansible.builtin.lineinfile: + line: "opcache.enable=1" + insertafter: ";opcache.enable=" + path: "{{ php_ini_file }}" + state: present + notify: reload php-fpm php7_fpm + tags: + - confphpfpm + +- name: "OP Cache for PHP{{ php_version }}" + ansible.builtin.lineinfile: + line: "opcache.enable_cli=1" + insertafter: ";opcache.enable_cli=" + path: "{{ php_ini_file }}" + state: present + notify: reload php-fpm php7_fpm + tags: + - confphpfpm + +- name: "OP Cache for PHP{{ php_version }}" + ansible.builtin.lineinfile: + line: "opcache.memory_consumption=128" + insertafter: ";opcache.memory_consumption" + path: "{{ php_ini_file }}" + state: present + notify: reload php-fpm php7_fpm + tags: + - confphpfpm diff --git a/roles/php7_fpm/tasks/configure_fpm_ini_nginx.yml b/roles/php7_fpm/tasks/configure_fpm_ini_nginx.yml new file mode 100644 index 0000000000000000000000000000000000000000..54387d76e2f3bdadfe4ace507ec29852a2ac8e31 --- /dev/null +++ b/roles/php7_fpm/tasks/configure_fpm_ini_nginx.yml @@ -0,0 +1,49 @@ +--- +# +# configure php.ini with nginx specific variables +# +- name: "Env[HOSTNAME] for PHP{{ php_version }}" + ansible.builtin.lineinfile: + line: "env[HOSTNAME] = $HOSTNAME" + insertafter: ";env\\[HOSTNAME\\] = \\$HOSTNAME" + path: "{{ php_www_conf_file }}" + state: present + backup: true + when: rev_proxy == "nginx" + notify: reload php-fpm php7_fpm + +- name: "Env[PATH] for PHP{{ php_version }}" + ansible.builtin.lineinfile: + line: "env[PATH] = /usr/local/bin:/usr/bin:/bin" + insertafter: ";env\\[PATH\\] = /usr/local/bin:/usr/bin:/bin" + path: "{{ php_www_conf_file }}" + state: present + when: rev_proxy == "nginx" + notify: reload php-fpm php7_fpm + +- name: "Env[TMP] for PHP{{ php_version }}" + ansible.builtin.lineinfile: + line: "env[TMP] = /tmp" + insertafter: ";env\\[TMP\\] = /tmp" + path: "{{ php_www_conf_file }}" + state: present + when: rev_proxy == "nginx" + notify: reload php-fpm php7_fpm + +- name: "Env[TMPDIR] for PHP{{ php_version }}" + ansible.builtin.lineinfile: + line: "env[TMPDIR] = /tmp" + insertafter: ";env\\[TMPDIR\\] = /tmp" + path: "{{ php_www_conf_file }}" + state: present + when: rev_proxy == "nginx" + notify: reload php-fpm php7_fpm + +- name: "Env[TEMP] for PHP{{ php_version }}" + ansible.builtin.lineinfile: + line: "env[TEMP] = /tmp" + insertafter: ";env\\[TEMP\\] = /tmp" + path: "{{ php_www_conf_file }}" + state: present + when: rev_proxy == "nginx" + notify: reload php-fpm php7_fpm diff --git a/roles/php7_fpm/tasks/main.yml b/roles/php7_fpm/tasks/main.yml index 2493a2af7ff040ff9d85ea94eb8cd054ea42de02..623c06240364c7476b8606ab2c8f2d0de7f1f8bc 100644 --- a/roles/php7_fpm/tasks/main.yml +++ b/roles/php7_fpm/tasks/main.yml @@ -1,65 +1,77 @@ --- - - import_role: - name: _app_log_inventory - vars: - log_type: "server" - server_name: "php-fpm" - - - name: "set fact php_ini_file" - set_fact: - php_ini_file: "{{ php_ini_file_apache2 }}" - when: rev_proxy == "apache2" - tags: - - setpath - - - name: "set fact php_ini_file" - set_fact: - php_ini_file: "{{ php_ini_file_nginx }}" - when: rev_proxy == "nginx" - tags: - - setpath - - - name: "PHP 7 repository for Ubuntu {{ ansible_distribution_release }}" - apt_repository: - repo: "ppa:ondrej/php" - state: present - when: ansible_distribution == 'Ubuntu' - tags: - - php - - - name: "PHP 7 repository for Debian {{ ansible_distribution_release }}" - block: +- name: "Check inventory" + ansible.builtin.import_role: + name: _app_log_inventory + vars: + log_type: "server" + server_name: "php-fpm" + +- name: "Set fact php_ini_file" + ansible.builtin.set_fact: + php_ini_file: "{{ php_ini_file_apache2 }}" + when: rev_proxy == "apache2" + tags: + - setpath + +- name: "Set fact php_ini_file" + ansible.builtin.set_fact: + php_ini_file: "{{ php_ini_file_nginx }}" + when: rev_proxy == "nginx" + tags: + - setpath + +- name: "PHP 7 repository for Ubuntu {{ ansible_distribution_release }}" + ansible.builtin.apt_repository: + repo: "ppa:ondrej/php" + state: present + when: ansible_distribution == 'Ubuntu' + tags: + - php + +- name: "PHP 7 repository for Debian {{ ansible_distribution_release }}" + when: ansible_distribution == 'Debian' + tags: + - php + block: - name: GPG key - apt_key: + ansible.builtin.apt_key: url: https://packages.sury.org/php/apt.gpg - name: Add APT repository - apt_repository: + ansible.builtin.apt_repository: repo: deb [arch=amd64] https://packages.sury.org/php/ {{ ansible_distribution_release }} main - when: ansible_distribution == 'Debian' - tags: - - php - - - name: "PHP packages" - apt: - name: "{{ php_package }}" - state: present - loop: "{{ php_packages }}" - loop_control: - loop_var: php_package - tags: - - php - - - name: "PHP package for apache" - apt: - name: "{{ php_apache_package }}" - state: present - loop: "{{ php_apache_packages }}" - loop_control: - loop_var: php_apache_package - notify: restart apache2 php7_fpm - when: rev_proxy == "apache2" + +- name: "PHP 7 packages" + ansible.builtin.apt: + name: "{{ php_package }}" + state: present + loop: "{{ php_7_packages }}" + loop_control: + loop_var: php_package + when: php_version is version('8.0', '<') + tags: + - php + +- name: "PHP common packages" + ansible.builtin.apt: + name: "{{ php_package }}" + state: present + loop: "{{ php_packages }}" + loop_control: + loop_var: php_package + tags: + - php + +- name: "PHP package for apache" + ansible.builtin.apt: + name: "{{ php_apache_package }}" + state: present + loop: "{{ php_apache_packages }}" + loop_control: + loop_var: php_apache_package + notify: restart apache2 php7_fpm + when: rev_proxy == "apache2" # TODO : review # - name: "a2enconf php{{ php_version }}" @@ -68,112 +80,63 @@ # changed_when: '"service apache2 reload" in __a2enconf_rc.stdout' # notify: restart apache2 - - name: "template for monitoring php{{ php_version }}-fpm" - template: - src: "php7-fpm.monit.j2" - dest: "/etc/monit/conf.d/php{{ php_version }}.conf" - notify: reload monit php7_fpm - - - - import_tasks: composer.yml - - - name: "redis server" - apt: name="redis-server" state=present - - - name: "start redis" - service: name=redis state=started - - - name: "cron stop redis.service for backup" - cron: - name: "stop redis" - hour: "{{ backup_web_stop_hour }}" - minute: "{{ backup_web_stop_minute }}" - job: "/bin/systemctl stop redis.service" - - - name: "cron start redis.service for backup" - cron: - name: "start redis" - hour: "{{ backup_web_start_hour }}" - minute: "{{ backup_web_start_minute }}" - job: "/bin/systemctl start redis.service" - - - name: "template for monitoring redis" - template: - src: "redis.monit.j2" - dest: "/etc/monit/conf.d/redis.conf" - notify: reload monit php7_fpm - - - import_tasks: configure_fpm.yml - - - name: "OP Cache for PHP{{ php_version }}" - lineinfile: - line: "opcache.enable=1" - insertafter: ";opcache.enable=" - path: "{{ php_ini_file }}" - state: present - backup: yes - notify: reload php-fpm php7_fpm - - - name: "OP Cache for PHP{{ php_version }}" - lineinfile: - line: "opcache.enable_cli=1" - insertafter: ";opcache.enable_cli=" - path: "{{ php_ini_file }}" - state: present - notify: reload php-fpm php7_fpm - - - name: "OP Cache for PHP{{ php_version }}" - lineinfile: - line: "opcache.memory_consumption=128" - insertafter: ";opcache.memory_consumption" - path: "{{ php_ini_file }}" - state: present - notify: reload php-fpm php7_fpm +- name: "Template for monitoring fpm php{{ php_version }}" + ansible.builtin.template: + src: "php7-fpm.monit.j2" + dest: "/etc/monit/conf.d/php{{ php_version }}.conf" + mode: u=rw,g=r,o=r + notify: reload monit php7_fpm + + +- name: "Download and install composer" + ansible.builtin.import_tasks: composer.yml + +- name: "Redis server" + ansible.builtin.apt: + name: "redis-server" + state: present + +- name: "Start redis" + ansible.builtin.service: + name: "redis" + state: started + +- name: "Cron stop redis.service for backup" + ansible.builtin.cron: + name: "stop redis" + hour: "{{ backup_web_stop_hour }}" + minute: "{{ backup_web_stop_minute }}" + job: "/bin/systemctl stop redis.service" + +- name: "Cron start redis.service for backup" + ansible.builtin.cron: + name: "start redis" + hour: "{{ backup_web_start_hour }}" + minute: "{{ backup_web_start_minute }}" + job: "/bin/systemctl start redis.service" + +- name: "Template for monitoring redis" + ansible.builtin.template: + src: "redis.monit.j2" + dest: "/etc/monit/conf.d/redis.conf" + mode: u=rw,g=r,o=r + notify: reload monit php7_fpm + +- name: "Configure php fpm for php{{ php_version }}" + ansible.builtin.import_tasks: configure_fpm.yml + tags: + - confphpfpm + +- name: "Configure php fpm ini file for php{{ php_version }}" + ansible.builtin.import_tasks: configure_fpm_ini.yml + tags: + - confphpfpm ### NGINX - - name: "env[HOSTNAME] for PHP{{ php_version }}" - lineinfile: - line: "env[HOSTNAME] = $HOSTNAME" - insertafter: ";env\\[HOSTNAME\\] = \\$HOSTNAME" - path: "{{ php_www_conf_file }}" - state: present - backup: yes - when: rev_proxy == "nginx" - notify: reload php-fpm php7_fpm - - - name: "env[PATH] for PHP{{ php_version }}" - lineinfile: - line: "env[PATH] = /usr/local/bin:/usr/bin:/bin" - insertafter: ";env\\[PATH\\] = /usr/local/bin:/usr/bin:/bin" - path: "{{ php_www_conf_file }}" - state: present - when: rev_proxy == "nginx" - notify: reload php-fpm php7_fpm - - - name: "env[TMP] for PHP{{ php_version }}" - lineinfile: - line: "env[TMP] = /tmp" - insertafter: ";env\\[TMP\\] = /tmp" - path: "{{ php_www_conf_file }}" - state: present - when: rev_proxy == "nginx" - notify: reload php-fpm php7_fpm - - - name: "env[TMPDIR] for PHP{{ php_version }}" - lineinfile: - line: "env[TMPDIR] = /tmp" - insertafter: ";env\\[TMPDIR\\] = /tmp" - path: "{{ php_www_conf_file }}" - state: present - when: rev_proxy == "nginx" - notify: reload php-fpm php7_fpm - - - name: "env[TEMP] for PHP{{ php_version }}" - lineinfile: - line: "env[TEMP] = /tmp" - insertafter: ";env\\[TEMP\\] = /tmp" - path: "{{ php_www_conf_file }}" - state: present - when: rev_proxy == "nginx" - notify: reload php-fpm php7_fpm +- name: "Configure php fpm ini file wiht Nginx specific config for php{{ php_version }}" + ansible.builtin.import_tasks: configure_fpm_ini_nginx.yml + when: rev_proxy == "nginx" + tags: + - confphpfpm + - fpm_nginx diff --git a/roles/php7_fpm/vars/main.yml b/roles/php7_fpm/vars/main.yml index 448d33336c69b92719e7e66d2b881c3d431c376f..e89499b7a18f6d3542543af647f2944082f8b41d 100644 --- a/roles/php7_fpm/vars/main.yml +++ b/roles/php7_fpm/vars/main.yml @@ -1,36 +1,39 @@ --- - # apache - php_ini_file_apache2: "/etc/php/{{ php_version }}/apache2/php.ini" - # nginx and other - php_ini_file_nginx: "/etc/php/{{ php_version }}/fpm/php.ini" +# apache +php_ini_file_apache2: "/etc/php/{{ php_version }}/apache2/php.ini" +# nginx and other +php_ini_file_nginx: "/etc/php/{{ php_version }}/fpm/php.ini" - php_www_conf_file: "/etc/php/{{ php_version }}/fpm/pool.d/www.conf" +php_www_conf_file: "/etc/php/{{ php_version }}/fpm/pool.d/www.conf" - php_packages: [ - "libmagickcore-6.q16-3-extra", - "imagemagick", - "php{{ php_version }}", - "php{{ php_version }}-bcmath", - "php{{ php_version }}-common", - "php{{ php_version }}-curl", - "php{{ php_version }}-fpm", - "php{{ php_version }}-gd", - "php{{ php_version }}-gmp", - "php{{ php_version }}-intl", - # php 8.1 ? "php{{ php_version }}-json", - "php{{ php_version }}-mbstring", - "php{{ php_version }}-imagick", - "php{{ php_version }}-mysql", - "php{{ php_version }}-pgsql", - "php{{ php_version }}-redis", - "php{{ php_version }}-sqlite3", - "php{{ php_version }}-xml", - "php{{ php_version }}-zip", - "composer", - "php{{ php_version }}-apcu" - ] +php_packages: [ + "libmagickcore-6.q16-3-extra", + "imagemagick", + "php{{ php_version }}", + "php{{ php_version }}-bcmath", + "php{{ php_version }}-common", + "php{{ php_version }}-curl", + "php{{ php_version }}-fpm", + "php{{ php_version }}-gd", + "php{{ php_version }}-gmp", + "php{{ php_version }}-intl", + "php{{ php_version }}-mbstring", + "php{{ php_version }}-imagick", + "php{{ php_version }}-mysql", + "php{{ php_version }}-pgsql", + "php{{ php_version }}-redis", + "php{{ php_version }}-sqlite3", + "php{{ php_version }}-xml", + "php{{ php_version }}-zip", + "composer", + "php{{ php_version }}-apcu" +] - php_apache_packages: [ - "libapache2-mod-php{{ php_version }}", - ] +php_7_packages: [ + "php{{ php_version }}-json" +] + +php_apache_packages: [ + "libapache2-mod-php{{ php_version }}", +]