tweak and simplify some of the apc and opcache configuration

This commit is contained in:
Patrick Force 2016-05-20 16:00:24 -06:00
parent b495937920
commit b9f0a61720
5 changed files with 34 additions and 15 deletions

View File

@ -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"

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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 }}