--- - name: Install PHP, PHP-FPM, and common extensions ansible.builtin.apt: name: "{{ httpd_php_pkgs }}" state: present update_cache: true - name: Enable Apache modules for PHP-FPM ansible.builtin.command: a2enmod {{ item }} loop: - proxy_fcgi - setenvif - php{{ httpd_php_version }} # or php8.1 depending on your distro notify: Reload Apache ignore_errors: true # in case some modules aren't available - name: Ensure PHP-FPM service is running ansible.builtin.service: name: php{{ httpd_php_version }}-fpm state: started enabled: true when: httpd_php_version is defined - name: Deploy custom PHP-FPM pool config ansible.builtin.template: src: php/www.conf.j2 dest: /etc/php/{{ httpd_php_version }}/fpm/pool.d/www.conf owner: root group: root mode: '0644' notify: Restart PHP-FPM