Skip to content

Commit b9f0a61

Browse files
committed
tweak and simplify some of the apc and opcache configuration
1 parent b495937 commit b9f0a61

File tree

5 files changed

+34
-15
lines changed

5 files changed

+34
-15
lines changed

README.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,6 @@ Various defaults for PHP. Only used if `php_use_managed_ini` is set to `true`.
8787

8888
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.
8989

90-
php_opcache_enabled_in_ini: false
91-
92-
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.
93-
9490
php_opcache_enable: "1"
9591
php_opcache_enable_cli: "0"
9692
php_opcache_memory_consumption: "96"
@@ -113,10 +109,6 @@ The platform-specific opcache configuration filename. Generally the default shou
113109

114110
Whether to enable APCu. Other APCu variables will be ineffective if this is set to false.
115111

116-
php_apc_enabled_in_ini: false
117-
118-
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.
119-
120112
php_apc_shm_size: "96M"
121113
php_apc_enable_cli: "0"
122114

defaults/main.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ php_fpm_pm_max_spare_servers: 5
1818
php_executable: "php"
1919

2020
# OpCache settings (useful for PHP >=5.5).
21-
php_opcache_enabled_in_ini: false
2221
php_opcache_enable: "1"
2322
php_opcache_enable_cli: "0"
2423
php_opcache_memory_consumption: "96"
@@ -32,7 +31,6 @@ php_opcache_blacklist_filename: ""
3231

3332
# APCu settings.
3433
php_enable_apc: true
35-
php_apc_enabled_in_ini: false
3634
php_apc_shm_size: "96M"
3735
php_apc_enable_cli: "0"
3836

tasks/configure.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,23 @@
1919
notify: restart webserver
2020
when: php_use_managed_ini
2121

22+
- name: Check for PHP-installed APCu configuration file(s)
23+
find:
24+
paths: "{{ item }}"
25+
contains: 'extension(\s+)?=(\s+)?apc[u]?\.so'
26+
register: php_installed_apc_confs
27+
with_items: "{{ php_extension_conf_paths }}"
28+
29+
- name: Remove any PHP-installed APCu configuration files in favor of role configuration
30+
file:
31+
path: "{{ item.1.path }}"
32+
state: absent
33+
when: php_apc_conf_filename != (item.1.path.split('/') | last)
34+
with_subelements:
35+
- "{{ php_installed_apc_confs.results }}"
36+
- files
37+
notify: restart webserver
38+
2239
- name: Place APCu configuration file in place.
2340
template:
2441
src: apc.ini.j2
@@ -31,6 +48,23 @@
3148
when: php_enable_apc
3249
notify: restart webserver
3350

51+
- name: Check for PHP-installed OpCache configuration file(s)
52+
find:
53+
paths: "{{ item }}"
54+
contains: 'zend_extension(\s+)?=(\s+)?opcache\.so'
55+
register: php_installed_opcache_confs
56+
with_items: "{{ php_extension_conf_paths }}"
57+
58+
- name: Remove any PHP-installed OpCache configuration files in favor of role configuration
59+
file:
60+
path: "{{ item.1.path }}"
61+
state: absent
62+
when: php_opcache_conf_filename != (item.1.path.split('/') | last)
63+
with_subelements:
64+
- "{{ php_installed_opcache_confs.results }}"
65+
- files
66+
notify: restart webserver
67+
3468
- name: Place OpCache configuration file in place.
3569
template:
3670
src: opcache.ini.j2

templates/apc.ini.j2

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
{% if php_apc_enabled_in_ini %}
21
extension=apcu.so
32
extension=apc.so
4-
{% endif %}
53
apc.shm_size={{ php_apc_shm_size }}
64
apc.enable_cli={{ php_apc_enable_cli }}
75
apc.rfc1867=1

templates/opcache.ini.j2

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
{% if php_opcache_enabled_in_ini %}
21
zend_extension=opcache.so
3-
{% endif %}
4-
52
opcache.enable={{ php_opcache_enable }}
63
opcache.enable_cli={{ php_opcache_enable_cli }}
74
opcache.memory_consumption={{ php_opcache_memory_consumption }}

0 commit comments

Comments
 (0)