mirror of
https://github.com/geerlingguy/ansible-role-php.git
synced 2024-11-30 13:03:26 +01:00
Merge branch 'master' of https://github.com/geerlingguy/ansible-role-php
This commit is contained in:
commit
9c5de4307a
16
.travis.yml
16
.travis.yml
@ -8,33 +8,27 @@ env:
|
||||
init: /usr/lib/systemd/systemd
|
||||
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
||||
SITE: source
|
||||
PHP_VERSION: 7.0.3
|
||||
PHP_VERSION: 7.0.5
|
||||
- distribution: ubuntu
|
||||
version: 14.04
|
||||
init: /sbin/init
|
||||
run_opts: ""
|
||||
SITE: source
|
||||
PHP_VERSION: 7.0.3
|
||||
PHP_VERSION: 7.0.5
|
||||
|
||||
# Test package install on all supported OSes.
|
||||
- distribution: centos
|
||||
version: 6
|
||||
init: /sbin/init
|
||||
run_opts: ""
|
||||
SITE: package
|
||||
PHP_VERSION: 5.6
|
||||
- distribution: centos
|
||||
version: 7
|
||||
init: /usr/lib/systemd/systemd
|
||||
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
||||
SITE: package
|
||||
PHP_VERSION: 5.6
|
||||
PHP_VERSION: 7.0
|
||||
- distribution: ubuntu
|
||||
version: 14.04
|
||||
init: /sbin/init
|
||||
run_opts: ""
|
||||
SITE: package
|
||||
PHP_VERSION: 5.6
|
||||
PHP_VERSION: 7.0
|
||||
- distribution: ubuntu
|
||||
version: 12.04
|
||||
init: /sbin/init
|
||||
@ -64,7 +58,7 @@ script:
|
||||
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test-${SITE}.yml --syntax-check'
|
||||
|
||||
# Test role.
|
||||
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test-${SITE}.yml'
|
||||
- 'travis_wait 30 sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test-${SITE}.yml'
|
||||
|
||||
# Test role idempotence.
|
||||
- >
|
||||
|
24
README.md
24
README.md
@ -6,7 +6,7 @@ Installs PHP on RedHat/CentOS and Debian/Ubuntu servers.
|
||||
|
||||
## Requirements
|
||||
|
||||
Must be running a separate web server, such as Nginx or Apache.
|
||||
If you're using an older LTS release of Ubuntu or RHEL, with an old/outdated version of PHP, you need to use a repo or PPA with a maintained PHP version, as this role only works with [PHP versions that are currently supported](http://php.net/supported-versions.php) by the PHP community.
|
||||
|
||||
## Role Variables
|
||||
|
||||
@ -16,7 +16,7 @@ Available variables are listed below, along with default values (see `defaults/m
|
||||
|
||||
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).
|
||||
|
||||
_Note: If you're using Debian/Ubuntu, you may also need to install `libapache2-mod-fastcgi` (for cgi/PHP-FPM) or `libapache2-mod-php5` (or a similar package depending on PHP version) if you want to use `mod_php` with Apache._
|
||||
_Note: If you're using Debian/Ubuntu, you also need to install `libapache2-mod-fastcgi` (for cgi/PHP-FPM) or `libapache2-mod-php7.0` (or a similar package depending on PHP version) if you want to use `mod_php` with Apache._
|
||||
|
||||
php_enable_webserver: true
|
||||
|
||||
@ -28,7 +28,7 @@ The default values for the HTTP server deamon are `httpd` (used by Apache) for R
|
||||
|
||||
php_enablerepo: ""
|
||||
|
||||
(RedHat/CentOS only) If you have enabled any additional repositories (might I suggest [geerlingguy.repo-epel](https://github.com/geerlingguy/ansible-role-repo-epel) or [geerlingguy.repo-remi](https://github.com/geerlingguy/ansible-role-repo-remi)), those repositories can be listed under this variable (e.g. `remi-php56,epel`). This can be handy, as an example, if you want to install the latest version of PHP 5.6, which is in the Remi repository.
|
||||
(RedHat/CentOS only) If you have enabled any additional repositories (might I suggest [geerlingguy.repo-epel](https://github.com/geerlingguy/ansible-role-repo-epel) or [geerlingguy.repo-remi](https://github.com/geerlingguy/ansible-role-repo-remi)), those repositories can be listed under this variable (e.g. `remi-php70,epel`). This can be handy, as an example, if you want to install the latest version of PHP 7.0, which is in the Remi repository.
|
||||
|
||||
php_packages_state: "installed"
|
||||
|
||||
@ -111,22 +111,20 @@ OpCache ini directives that are often customized on a system. Make sure you have
|
||||
|
||||
The platform-specific opcache configuration filename. Generally the default should work, but in some cases, you may need to override the filename.
|
||||
|
||||
### APC-related Variables
|
||||
### APCu-related Variables
|
||||
|
||||
php_enable_apc: true
|
||||
|
||||
Whether to enable APC. Other APC variables will be ineffective if this is set to false.
|
||||
Whether to enable APCu. Other APCu variables will be ineffective if this is set to false.
|
||||
|
||||
php_apc_enabled_in_ini: false
|
||||
|
||||
When installing APC, depending on the system and whether running PHP as a webserver module or standalone via `php-fpm`, you might need the line `extension=apc.so` in `apc.ini`. If you need that line added (e.g. you're running `php-fpm`), set this variable to true.
|
||||
When installing APCu, depending on the system and whether running PHP as a webserver module or standalone via `php-fpm`, you might need the line `extension=apc.so` in `apc.ini`. If you need that line added (e.g. you're running `php-fpm`), set this variable to true.
|
||||
|
||||
php_apc_cache_by_default: "1"
|
||||
php_apc_shm_size: "96M"
|
||||
php_apc_stat: "1"
|
||||
php_apc_enable_cli: "0"
|
||||
|
||||
APC ini directives that are often customized on a system. Set `php_apc_cache_by_default` to 0 to disable APC by default (so you could just enable it for one codebase if you have a *lot* of code on a server). Set the `php_apc_shm_size` so it will hold all your application code in memory with a little overhead (fragmentation or APC running out of memory will slow down PHP *dramatically*).
|
||||
APCu ini directives that are often customized on a system. Set the `php_apc_shm_size` so it will hold all cache entries in memory with a little overhead (fragmentation or APC running out of memory will slow down PHP *dramatically*).
|
||||
|
||||
php_apc_conf_filename: [platform-specific]
|
||||
|
||||
@ -136,10 +134,8 @@ The platform-specific APC configuration filename. Generally the default should w
|
||||
|
||||
If you use APC, you will need to make sure APC is installed (it is installed by default, but if you customize the `php_packages` list, you need to include APC in the list):
|
||||
|
||||
- *On RHEL/CentOS systems*: Make sure `php-pecl-apc` is in the list of `php_packages`.
|
||||
- *On Debian/Ubuntu systems*: Make sure `php-apc` is in the list of `php_packages`.
|
||||
|
||||
You can also install APC via `pecl`, but it's simpler to manage the installation with the system's package manager.
|
||||
- *On RHEL/CentOS systems*: Make sure `php-pecl-apcu` is in the list of `php_packages`.
|
||||
- *On Debian/Ubuntu systems*: Make sure `php-apcu` is in the list of `php_packages`.
|
||||
|
||||
### Installing from Source
|
||||
|
||||
@ -201,7 +197,7 @@ None.
|
||||
- php-gd
|
||||
- php-mbstring
|
||||
- php-pdo
|
||||
- php-pecl-apc
|
||||
- php-pecl-apcu
|
||||
- php-xml
|
||||
...
|
||||
|
||||
|
@ -33,12 +33,10 @@ php_opcache_revalidate_freq: "2"
|
||||
php_opcache_max_file_size: "0"
|
||||
php_opcache_blacklist_filename: ""
|
||||
|
||||
# APC settings (useful for PHP <5.5).
|
||||
# APCu settings.
|
||||
php_enable_apc: true
|
||||
php_apc_enabled_in_ini: false
|
||||
php_apc_cache_by_default: "1"
|
||||
php_apc_shm_size: "96M"
|
||||
php_apc_stat: "1"
|
||||
php_apc_enable_cli: "0"
|
||||
|
||||
# If this is set to false, none of the following options will have any effect.
|
||||
|
@ -9,6 +9,11 @@
|
||||
php_fpm_pool_conf_path: "{{ __php_fpm_pool_conf_path }}"
|
||||
when: php_fpm_pool_conf_path is not defined
|
||||
|
||||
- name: Stat php_fpm_pool_conf_path
|
||||
stat:
|
||||
path: "{{ php_fpm_pool_conf_path | dirname }}"
|
||||
register: php_fpm_pool_conf_path_dir_stat
|
||||
|
||||
- name: Ensure the default pool directory exists.
|
||||
file:
|
||||
path: "{{ php_fpm_pool_conf_path | dirname }}"
|
||||
@ -16,6 +21,7 @@
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
when: php_fpm_pool_conf_path_dir_stat.stat.islnk is not defined
|
||||
|
||||
- name: Ensure the default pool exists.
|
||||
copy:
|
||||
|
@ -19,7 +19,7 @@
|
||||
notify: restart webserver
|
||||
when: php_use_managed_ini
|
||||
|
||||
- name: Place APC configuration file in place.
|
||||
- name: Place APCu configuration file in place.
|
||||
template:
|
||||
src: apc.ini.j2
|
||||
dest: "{{ item }}/{{ php_apc_conf_filename }}"
|
||||
|
@ -28,6 +28,11 @@
|
||||
php_apc_conf_filename: "{{ __php_apc_conf_filename }}"
|
||||
when: php_apc_conf_filename is not defined
|
||||
|
||||
- name: Define php_opcache_conf_filename (Ubuntu 16.04).
|
||||
set_fact:
|
||||
php_opcache_conf_filename: "10-opcache.ini"
|
||||
when: php_opcache_conf_filename is not defined and ansible_distribution_version == "16.04"
|
||||
|
||||
- name: Define php_opcache_conf_filename.
|
||||
set_fact:
|
||||
php_opcache_conf_filename: "{{ __php_opcache_conf_filename }}"
|
||||
@ -49,17 +54,6 @@
|
||||
- include: install-from-source.yml
|
||||
when: php_install_from_source == true
|
||||
|
||||
- name: Check the installed version of PHP.
|
||||
shell: '{{ php_executable }} -r "echo PHP_VERSION;"'
|
||||
register: php_installed_version
|
||||
changed_when: false
|
||||
always_run: yes
|
||||
|
||||
- name: Disable opcache if PHP version is < 5.5.
|
||||
set_fact:
|
||||
php_opcache_enable: 0
|
||||
when: "{{ php_installed_version.stdout | version_compare('5.5', operator='lt') }}"
|
||||
|
||||
# Configure PHP.
|
||||
- include: configure.yml
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
register: php_package_install
|
||||
notify: restart webserver
|
||||
|
||||
- name: Delete APC configuration file if this role will provide one.
|
||||
- name: Delete APCu configuration file if this role will provide one.
|
||||
file:
|
||||
path: "{{ item }}/{{ php_apc_conf_filename }}"
|
||||
state: absent
|
||||
|
@ -1,8 +1,7 @@
|
||||
{% if php_apc_enabled_in_ini %}
|
||||
extension=apcu.so
|
||||
extension=apc.so
|
||||
{% endif %}
|
||||
apc.shm_size={{ php_apc_shm_size }}
|
||||
apc.stat={{ php_apc_stat }}
|
||||
apc.enable_cli={{ php_apc_enable_cli }}
|
||||
apc.rfc1867=1
|
||||
apc.cache_by_default={{ php_apc_cache_by_default }}
|
||||
|
@ -1,15 +0,0 @@
|
||||
FROM centos:6
|
||||
|
||||
# Install Ansible
|
||||
RUN yum -y update; yum clean all;
|
||||
RUN yum -y install epel-release
|
||||
RUN yum -y install git ansible sudo
|
||||
RUN yum clean all
|
||||
|
||||
# Disable requiretty
|
||||
RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers
|
||||
|
||||
# Install Ansible inventory file
|
||||
RUN echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts
|
||||
|
||||
CMD ["/usr/sbin/init"]
|
@ -3,18 +3,24 @@
|
||||
|
||||
vars:
|
||||
php_enable_webserver: false
|
||||
php_version: 5.6
|
||||
php_memory_limit: "192M"
|
||||
php_enablerepo: "remi,remi-php56"
|
||||
php_enablerepo: "remi,remi-php70"
|
||||
|
||||
pre_tasks:
|
||||
- include_vars: test-vars-ubuntu1204.yml
|
||||
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '12.04'
|
||||
|
||||
- name: Ensure build dependencies are installed (RedHat).
|
||||
yum: name=which state=present
|
||||
when: ansible_os_family == 'RedHat'
|
||||
|
||||
- name: Add repository for PHP 7.
|
||||
apt_repository: repo='ppa:ondrej/php'
|
||||
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version != '12.04'
|
||||
|
||||
- name: Add repository for PHP 5.6.
|
||||
apt_repository: repo='ppa:ondrej/php5-5.6'
|
||||
when: ansible_os_family == 'Debian'
|
||||
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '12.04'
|
||||
|
||||
roles:
|
||||
- { role: geerlingguy.repo-remi, when: ansible_os_family == 'RedHat' }
|
||||
|
@ -6,7 +6,7 @@
|
||||
php_install_from_source: true
|
||||
php_source_clone_dir: /root/php-src
|
||||
php_source_make_command: "make --jobs=2"
|
||||
php_source_version: "php-7.0.3"
|
||||
php_source_version: "php-7.0.5"
|
||||
php_memory_limit: "192M"
|
||||
|
||||
pre_tasks:
|
||||
|
23
tests/test-vars-ubuntu1204.yml
Normal file
23
tests/test-vars-ubuntu1204.yml
Normal file
@ -0,0 +1,23 @@
|
||||
---
|
||||
php_version: "5.6"
|
||||
php_packages:
|
||||
- php5
|
||||
- php5-mcrypt
|
||||
- php5-cli
|
||||
- php5-common
|
||||
- php5-curl
|
||||
- php5-dev
|
||||
- php5-fpm
|
||||
- php5-gd
|
||||
- php-pear
|
||||
- libpcre3-dev
|
||||
php_conf_paths:
|
||||
- /etc/php5/fpm
|
||||
- /etc/php5/apache2
|
||||
- /etc/php5/cli
|
||||
php_extension_conf_paths:
|
||||
- /etc/php5/fpm/conf.d
|
||||
- /etc/php5/apache2/conf.d
|
||||
- /etc/php5/cli/conf.d
|
||||
php_fpm_daemon: php5-fpm
|
||||
php_fpm_conf_path: "/etc/php5/fpm"
|
@ -1,31 +1,34 @@
|
||||
---
|
||||
__php_packages:
|
||||
- php5
|
||||
- php5-mcrypt
|
||||
- php5-cli
|
||||
- php5-common
|
||||
- php5-curl
|
||||
- php5-dev
|
||||
- php5-fpm
|
||||
- php5-gd
|
||||
- php-pear
|
||||
- php-apc
|
||||
- php7.0-common
|
||||
- php7.0-cli
|
||||
- php7.0-dev
|
||||
- php7.0-fpm
|
||||
- libpcre3-dev
|
||||
- php7.0-gd
|
||||
- php7.0-curl
|
||||
- php7.0-imap
|
||||
- php7.0-json
|
||||
- php7.0-opcache
|
||||
- php7.0-xml
|
||||
- php7.0-mbstring
|
||||
- php-sqlite3
|
||||
- php-apcu
|
||||
__php_webserver_daemon: "apache2"
|
||||
|
||||
# Vendor-specific configuration paths on Debian/Ubuntu make my brain asplode.
|
||||
__php_conf_paths:
|
||||
- /etc/php5/fpm
|
||||
- /etc/php5/apache2
|
||||
- /etc/php5/cli
|
||||
- /etc/php/7.0/fpm
|
||||
- /etc/php/7.0/apache2
|
||||
- /etc/php/7.0/cli
|
||||
|
||||
__php_extension_conf_paths:
|
||||
- /etc/php5/fpm/conf.d
|
||||
- /etc/php5/apache2/conf.d
|
||||
- /etc/php5/cli/conf.d
|
||||
- /etc/php/7.0/fpm/conf.d
|
||||
- /etc/php/7.0/apache2/conf.d
|
||||
- /etc/php/7.0/cli/conf.d
|
||||
|
||||
__php_apc_conf_filename: 20-apcu.ini
|
||||
__php_opcache_conf_filename: 05-opcache.ini
|
||||
__php_fpm_daemon: php5-fpm
|
||||
__php_fpm_conf_path: "/etc/php5/fpm"
|
||||
__php_fpm_daemon: php7.0-fpm
|
||||
__php_fpm_conf_path: "/etc/php/7.0/fpm"
|
||||
__php_fpm_pool_conf_path: "{{ __php_fpm_conf_path }}/pool.d/www.conf"
|
||||
|
@ -12,7 +12,7 @@ __php_packages:
|
||||
- php-opcache
|
||||
- php-pdo
|
||||
- php-pear
|
||||
- php-pecl-apc
|
||||
- php-pecl-apcu
|
||||
- php-xml
|
||||
- php-xmlrpc
|
||||
__php_webserver_daemon: "httpd"
|
||||
|
Loading…
Reference in New Issue
Block a user