From b9f0a6172000fb834a95fb30f5c46cafe03f4331 Mon Sep 17 00:00:00 2001 From: Patrick Force Date: Fri, 20 May 2016 16:00:24 -0600 Subject: [PATCH] tweak and simplify some of the apc and opcache configuration --- README.md | 8 -------- defaults/main.yml | 2 -- tasks/configure.yml | 34 ++++++++++++++++++++++++++++++++++ templates/apc.ini.j2 | 2 -- templates/opcache.ini.j2 | 3 --- 5 files changed, 34 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index bfd8189..024210a 100644 --- a/README.md +++ b/README.md @@ -87,10 +87,6 @@ Various defaults for PHP. Only used if `php_use_managed_ini` is set to `true`. The OpCache is included in PHP starting in version 5.5, and the following variables will only take effect if the version of PHP you have installed is 5.5 or greater. - php_opcache_enabled_in_ini: false - -When installing Opcache, depending on the system and whether running PHP as a webserver module or standalone via `php-fpm`, you might need the line `extension=opcache.so` in `opcache.ini`. If you need that line added (e.g. you're running `php-fpm`), set this variable to true. - php_opcache_enable: "1" php_opcache_enable_cli: "0" php_opcache_memory_consumption: "96" @@ -113,10 +109,6 @@ The platform-specific opcache configuration filename. Generally the default shou Whether to enable APCu. Other APCu variables will be ineffective if this is set to false. - php_apc_enabled_in_ini: false - -When installing APCu, depending on the system and whether running PHP as a webserver module or standalone via `php-fpm`, you might need the line `extension=apc.so` in `apc.ini`. If you need that line added (e.g. you're running `php-fpm`), set this variable to true. - php_apc_shm_size: "96M" php_apc_enable_cli: "0" diff --git a/defaults/main.yml b/defaults/main.yml index ba3fc8f..8059a84 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -18,7 +18,6 @@ php_fpm_pm_max_spare_servers: 5 php_executable: "php" # OpCache settings (useful for PHP >=5.5). -php_opcache_enabled_in_ini: false php_opcache_enable: "1" php_opcache_enable_cli: "0" php_opcache_memory_consumption: "96" @@ -32,7 +31,6 @@ php_opcache_blacklist_filename: "" # APCu settings. php_enable_apc: true -php_apc_enabled_in_ini: false php_apc_shm_size: "96M" php_apc_enable_cli: "0" diff --git a/tasks/configure.yml b/tasks/configure.yml index 9b21a70..33f0444 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -19,6 +19,23 @@ notify: restart webserver when: php_use_managed_ini +- name: Check for PHP-installed APCu configuration file(s) + find: + paths: "{{ item }}" + contains: 'extension(\s+)?=(\s+)?apc[u]?\.so' + register: php_installed_apc_confs + with_items: "{{ php_extension_conf_paths }}" + +- name: Remove any PHP-installed APCu configuration files in favor of role configuration + file: + path: "{{ item.1.path }}" + state: absent + when: php_apc_conf_filename != (item.1.path.split('/') | last) + with_subelements: + - "{{ php_installed_apc_confs.results }}" + - files + notify: restart webserver + - name: Place APCu configuration file in place. template: src: apc.ini.j2 @@ -31,6 +48,23 @@ when: php_enable_apc notify: restart webserver +- name: Check for PHP-installed OpCache configuration file(s) + find: + paths: "{{ item }}" + contains: 'zend_extension(\s+)?=(\s+)?opcache\.so' + register: php_installed_opcache_confs + with_items: "{{ php_extension_conf_paths }}" + +- name: Remove any PHP-installed OpCache configuration files in favor of role configuration + file: + path: "{{ item.1.path }}" + state: absent + when: php_opcache_conf_filename != (item.1.path.split('/') | last) + with_subelements: + - "{{ php_installed_opcache_confs.results }}" + - files + notify: restart webserver + - name: Place OpCache configuration file in place. template: src: opcache.ini.j2 diff --git a/templates/apc.ini.j2 b/templates/apc.ini.j2 index 468c27a..1fec9b1 100644 --- a/templates/apc.ini.j2 +++ b/templates/apc.ini.j2 @@ -1,7 +1,5 @@ -{% if php_apc_enabled_in_ini %} extension=apcu.so extension=apc.so -{% endif %} apc.shm_size={{ php_apc_shm_size }} apc.enable_cli={{ php_apc_enable_cli }} apc.rfc1867=1 diff --git a/templates/opcache.ini.j2 b/templates/opcache.ini.j2 index 7328664..7d97e2b 100644 --- a/templates/opcache.ini.j2 +++ b/templates/opcache.ini.j2 @@ -1,7 +1,4 @@ -{% if php_opcache_enabled_in_ini %} zend_extension=opcache.so -{% endif %} - opcache.enable={{ php_opcache_enable }} opcache.enable_cli={{ php_opcache_enable_cli }} opcache.memory_consumption={{ php_opcache_memory_consumption }}