Installing PHP

Like the previous three parts of the stack, we are going to start by installing the packages. As before, we are defining a variable in roles/php/default/main.yml that lists all of the packages we need:

php_packages:  - "php72u"  - "php72u-bcmath"  - "php72u-cli"  - "php72u-common"  - "php72u-dba"  - "php72u-fpm"  - "php72u-fpm-httpd"  - "php72u-gd"  - "php72u-intl"  - "php72u-json"  - "php72u-mbstring"  - "php72u-mysqlnd"  - "php72u-odbc"  - "php72u-pdo"  - "php72u-process"  - "php72u-snmp"  - "php72u-soap"  - "php72u-xml"  - "php72u-xmlrpc"

This is installed by using the YUM module in php/roles/tasks/main.yml:

- name: install the php packages  yum:    name: "{{ item }}"    state: "installed"  with_items: "{{ php_packages }}"  notify: - "restart php-fpm" ...

Get Learn Ansible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.