Add php-fpm support, remove Apache dependency (works with Nginx).

This commit is contained in:
Jeff Geerling 2014-05-02 22:27:28 -05:00
parent 3a6d641399
commit 7908233ae6
6 changed files with 24 additions and 9 deletions

View File

@ -6,7 +6,7 @@ Installs PHP on RedHat/CentOS and Debian/Ubuntu servers.
## Requirements ## Requirements
None. Must be running a separate web server, such as Nginx or Apache.
## Role Variables ## Role Variables
@ -33,13 +33,21 @@ Explicitly set PHP's date timezone system-wide.
A list of the PHP packages to install (OS-specific by default). You'll likely want to install common packages like `php`, `php-cli`, `php-devel` and `php-pdo`, and you can add in whatever other packages you'd like (for example, `php-gd` for image manipulation, or `php-ldap` if you need to connect to an LDAP server for authentication). A list of the PHP packages to install (OS-specific by default). You'll likely want to install common packages like `php`, `php-cli`, `php-devel` and `php-pdo`, and you can add in whatever other packages you'd like (for example, `php-gd` for image manipulation, or `php-ldap` if you need to connect to an LDAP server for authentication).
php_webserver_daemon: "httpd"
The default values for the HTTP server deamon are `httpd` (used by Apache) for RedHat/CentOS, or `apache2` (also used by Apache) for Debian/Ubuntu. If you are running another webserver (for example, `nginx`), change this value to the name of the daemon under which the webserver runs.
php_enable_php_fpm: false
If you add `php-fpm` to the `php_packages` list, and would like to run PHP-fpm, as you would with Nginx or as an alternative to `mod_php` in Apache, you can set this variable to `true`, and the `php-fpm` daemon will be enabled and started. You will need to configure PHP-fpm on your own, by editing the config file in `/etc/php-fpm.d/www.conf` (for RedHat servers) or replacing it with your own template via Ansible.
php_enablerepo: "" php_enablerepo: ""
(RedHat/CentOS only) If you have enabled any additional repositories (might I suggest geerlingguy.repo-epel or geerlingguy.repo-remi), those repositories can be listed under this variable (e.g. `remi,epel`). This can be handy, as an example, if you want to install the latest version of PHP 5.4, which is in the Remi repository. (RedHat/CentOS only) If you have enabled any additional repositories (might I suggest geerlingguy.repo-epel or geerlingguy.repo-remi), those repositories can be listed under this variable (e.g. `remi,epel`). This can be handy, as an example, if you want to install the latest version of PHP 5.4, which is in the Remi repository.
## Dependencies ## Dependencies
- geerlingguy.apache None.
## Example Playbook ## Example Playbook
@ -70,7 +78,6 @@ A list of the PHP packages to install (OS-specific by default). You'll likely wa
- Make role more flexible, allowing APC to be excluded from `php_packages` list. - Make role more flexible, allowing APC to be excluded from `php_packages` list.
- Use `lineinfile` rather than templates to make configuration changes. - Use `lineinfile` rather than templates to make configuration changes.
- Remove apache dependency (better way of using handler? Way to get around Debian/apt's apache2 + php bindings?).
## License ## License

View File

@ -1,6 +1,5 @@
--- ---
dependencies: dependencies: []
- { role: geerlingguy.apache }
galaxy_info: galaxy_info:
author: geerlingguy author: geerlingguy

View File

@ -8,7 +8,7 @@
state=installed state=installed
enablerepo={{ php_enablerepo }} enablerepo={{ php_enablerepo }}
with_items: php_packages with_items: php_packages
notify: restart apache notify: restart webserver
when: ansible_os_family == 'RedHat' when: ansible_os_family == 'RedHat'
- name: Ensure PHP packages are installed (Debian). - name: Ensure PHP packages are installed (Debian).
@ -16,7 +16,7 @@
name={{ item }} name={{ item }}
state=installed state=installed
with_items: php_packages with_items: php_packages
notify: restart apache notify: restart webserver
when: ansible_os_family == 'Debian' when: ansible_os_family == 'Debian'
- name: Place PHP configuration files in place. - name: Place PHP configuration files in place.
@ -27,4 +27,8 @@
with_items: with_items:
- { src: php.ini.j2, dest: "{{ php_conf_path }}/php.ini" } - { src: php.ini.j2, dest: "{{ php_conf_path }}/php.ini" }
- { src: apc.ini.j2, dest: "{{ php_extension_conf_path }}/{{ php_apc_conf_filename }}" } - { src: apc.ini.j2, dest: "{{ php_extension_conf_path }}/{{ php_apc_conf_filename }}" }
notify: restart apache notify: restart webserver
- name: Ensure php-fpm is started and enabled at boot (if configured).
service: name=php-fpm state=started enabled=yes
when: php_enable_php_fpm

View File

@ -13,3 +13,4 @@ php_packages:
- php5-gd - php5-gd
- php5-ldap - php5-ldap
- php-apc - php-apc
php_webserver_daemon: "apache2"

View File

@ -16,4 +16,5 @@ php_packages:
- php-pear - php-pear
- php-pecl-apc - php-pecl-apc
- php-xml - php-xml
- php-xmlrpc - php-xmlrpc
php_webserver_daemon: "httpd"

View File

@ -8,3 +8,6 @@ php_apc_cache_by_default: "1"
php_apc_shm_size: "96M" php_apc_shm_size: "96M"
php_date_timezone: "America/Chicago" php_date_timezone: "America/Chicago"
php_packages: [] php_packages: []
php_webserver_daemon: "httpd"
php_enable_php_fpm: false