Skip to content
Permalink
master
Switch branches/tags
Go to file
Refactors how PHP and its extensions are installed per version.
Previously all version references were hardcoded and updating to a new
version (ie from `7.4` to `8.0`) meant replacing a bunch of version
numbers across lots of files which made it difficult to use a different
version than Trellis' default.

Now to switch to another PHP version that Trellis supports, only the
`php_version` variable needs to be changed. And to support a new
version, only a single version specific vars file needs to be created
(example: `roles/php/vars/8.0.yml`).
10 contributors

Users who have contributed to this file

@swalkinshaw @TangRufus @fullyint @kalenjohnson @BrandonShutter @retlehs @akovalyov @RiFi2k @cam5 @markjaquith
---
- name: Add PHP PPA
apt_repository:
repo: "ppa:ondrej/php"
update_cache: yes
- name: Install PHP and extensions
apt:
name: "{{ item.key }}"
state: "{{ item.value }}"
cache_valid_time: "{{ apt_cache_valid_time }}"
with_dict: "{{ php_extensions }}"
- name: Start php fpm service
service:
name: "php{{ php_version }}-fpm"
state: started
enabled: true
- name: Find existing php fpm services
find:
paths: /etc/init.d
patterns: "^php((?!{{ php_version }})(\\d\\.\\d))-fpm$"
use_regex: true
register: old_php_fpm_services
- name: Stop old php-fpm services
service:
name: "{{ item.path | basename }}"
state: stopped
enabled: false
loop: "{{ old_php_fpm_services.files }}"
loop_control:
label: "{{ item.path | basename }}"
notify: reload php-fpm
- name: Copy PHP-FPM configuration file
template:
src: php-fpm.ini.j2
dest: /etc/php/{{ php_version }}/fpm/php.ini
mode: '0644'
notify: reload php-fpm
- name: Copy PHP CLI configuration file
template:
src: php-cli.ini.j2
dest: /etc/php/{{ php_version }}/cli/php.ini
mode: '0644'