geerlingguy.apache-php-fpm
Ansible Role: Apache PHP-FPM
This Ansible Role sets up Apache to work with PHP-FPM on RHEL/CentOS and Debian/Ubuntu systems.
Requirements
To use this role, you need the geerlingguy.apache
role and have PHP-FPM installed and running on your server (I typically use the geerlingguy.php
role to set up PHP).
When setting up your Apache virtual hosts, include this line to connect to PHP-FPM:
# For TCP port:
ProxyPassMatch ^/(.*\.php(/.*)?)$ "fcgi://127.0.0.1:9000/var/www/example"
# For Unix socket:
ProxyPassMatch ^/(.*\.php(/.*)?)$ "unix:/var/run/php5-fpm.sock|fcgi://localhost/var/www/example"
For a complete example using the geerlingguy.apache
role, check the Example Playbook section below.
RedHat 6 and 7
On RedHat/CentOS 7, the mod_proxy_fcgi module is installed and enabled by default.
For RedHat/CentOS 6, which uses Apache 2.2, getting FastCGI to work can be more challenging. Here are two guides if you need help:
Role Variables
There are no role variables.
Dependencies
There are no dependencies.
Example Playbook
- hosts: webservers
vars:
php_enable_php_fpm: true
apache_vhosts:
- servername: "www.example.com"
documentroot: "/var/www/example"
extra_parameters: |
ProxyPassMatch ^/(.*\.php(/.*)?)$ "fcgi://127.0.0.1:9000/var/www/example"
roles:
- geerlingguy.apache
- geerlingguy.php
- geerlingguy.apache-php-fpm
License
MIT / BSD
Author Information
This role was created in 2016 by Jeff Geerling, the author of Ansible for DevOps.
ansible-galaxy install geerlingguy.apache-php-fpm