mirror of
https://github.com/geerlingguy/ansible-role-php.git
synced 2024-11-28 12:45:16 +01:00
Fixes #24: Configure OpCache for PHP >= 5.5.
This commit is contained in:
parent
b476fa740c
commit
c1cf287346
@ -8,6 +8,18 @@ php_enable_webserver: true
|
||||
# Start and enable the PHP fpm service.
|
||||
php_enable_php_fpm: false
|
||||
|
||||
# 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"
|
||||
php_opcache_interned_strings_buffer: "16"
|
||||
php_opcache_max_accelerated_files: "4096"
|
||||
php_opcache_max_wasted_percentage: "5"
|
||||
php_opcache_validate_timestamps: "1"
|
||||
php_opcache_revalidate_freq: "2"
|
||||
php_opcache_max_file_size: "0"
|
||||
|
||||
# APC settings (useful for PHP <5.5).
|
||||
php_enable_apc: true
|
||||
php_apc_enabled_in_ini: false
|
||||
|
@ -29,6 +29,17 @@
|
||||
when: php_enable_apc
|
||||
notify: restart webserver
|
||||
|
||||
- name: Place OpCache configuration file in place.
|
||||
template:
|
||||
src: opcache.ini.j2
|
||||
dest: "{{ php_extension_conf_path }}/{{ php_opcache_conf_filename }}"
|
||||
owner: root
|
||||
group: root
|
||||
force: yes
|
||||
mode: 0644
|
||||
when: php_opcache_enable
|
||||
notify: restart webserver
|
||||
|
||||
- name: Ensure php-fpm is started and enabled at boot (if configured).
|
||||
service:
|
||||
name: "{{ php_fpm_daemon }}"
|
||||
|
@ -30,5 +30,15 @@
|
||||
- include: setup-Debian.yml
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
- name: Check the installed version of PHP.
|
||||
shell: php -r "echo PHP_VERSION;"
|
||||
register: php_version
|
||||
changed_when: false
|
||||
|
||||
- name: Disable opcache if PHP version is < 5.5.
|
||||
set_fact:
|
||||
php_opcache_enable: 0
|
||||
when: "php_version.stdout.split('.')[0] == '5' and php_version.stdout.split('.')[1] < '5'"
|
||||
|
||||
# Configure PHP.
|
||||
- include: configure.yml
|
||||
|
13
templates/opcache.ini.j2
Normal file
13
templates/opcache.ini.j2
Normal file
@ -0,0 +1,13 @@
|
||||
{% 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 }}
|
||||
opcache.interned_strings_buffer={{ php_opcache_interned_strings_buffer }}
|
||||
opcache.max_accelerated_files={{ php_opcache_max_accelerated_files }}
|
||||
opcache.max_wasted_percentage={{ php_opcache_max_wasted_percentage }}
|
||||
opcache.validate_timestamps={{ php_opcache_validate_timestamps }}
|
||||
opcache.revalidate_freq={{ php_opcache_revalidate_freq }}
|
||||
opcache.max_file_size={{ php_opcache_max_file_size }}
|
@ -19,4 +19,5 @@ __php_conf_path: "{{ '/etc/php5' if php_webserver_daemon and php_webserver_daemo
|
||||
__php_extension_conf_path: "{{ __php_conf_path }}/conf.d"
|
||||
|
||||
php_apc_conf_filename: 20-apc.ini
|
||||
php_opcache_conf_filename: 05-opcache.ini
|
||||
php_fpm_daemon: php5-fpm
|
||||
|
@ -21,4 +21,5 @@ __php_conf_path: /etc
|
||||
php_extension_conf_path: /etc/php.d
|
||||
|
||||
php_apc_conf_filename: apc.ini
|
||||
php_opcache_conf_filename: opcache.ini
|
||||
php_fpm_daemon: php-fpm
|
||||
|
Loading…
Reference in New Issue
Block a user