Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • ansible/roles/php
  • ericzillmann/php
2 results
Show changes
Showing with 1134 additions and 132 deletions
---
# file: roles/php/handlers/main.yml
- name: Restart PHP-FPM
service:
name: '{{ phpFpmService }}'
state: restarted
- name: Initial Logrotate
shell: logrotate -f /etc/logrotate.d/php{{ phpLogRotatePrefix }}-fpm
---
dependencies:
- { role: apache }
- { role: imagemagick }
......@@ -5,9 +5,36 @@
---
# file: roles/php/tasks/main.yml
- include: php.yml
when: role_php_completed is not defined
- name: PHP Role
set_fact:
role_php_started: yes
tags:
- always
- name: 'PHP | Remember that this role had been run'
set_fact: role_php_completed=true
when: role_php_completed is not defined
- block:
- name: Include variables
include_tasks: variables.yml
tags:
- always
- name: Import php
import_tasks: php.yml
- name: Link PhpEnMod for PHP 5.3
file:
dest: /usr/local/bin/php{{ item }}
src: /usr/sbin/php5{{ item }}
state: link
with_items:
- enmod
- dismod
when: php_version|default("5.5") == "5.3"
- name: PHP | Remember that this role had been run
set_fact:
role_php_completed: yes
tags:
- always
when: (not excluded_roles or "php" not in excluded_roles) and role_php_completed is not defined
---
# file: roles/php/tasks/mcrypt-7.2.yml
- name: Check MCrypt Requirement
stat:
path: /usr/lib/php/20170718/mcrypt.so
register: mcrypt_file
- block:
- name: Enable MCrypt for PHP
copy:
content: extension={{ item }}.so
dest: /etc/{{ php_base_dir }}/{{ php_conf_dir }}/{{ item }}.ini
owner: root
group: root
mode: 0644
with_items:
- mcrypt
- name: Install packages
apt:
pkg: '{{ packages }}'
state: present
update_cache: yes
vars:
packages:
- libmcrypt-dev
- libreadline-dev
- name: Install PECL packages
shell: pecl install --soft --ignore-errors mcrypt-1.0.1
when: php_version_main|default(7) == 7
ignore_errors: yes
- name: Enable extension
shell: phpenmod {{ item }}
with_items:
- mcrypt
notify:
- Restart Apache
when: not mcrypt_file.stat.exists
---
# file: roles/php/tasks/msodbc.yml
- name: Apt Key
apt_key:
keyring: /etc/apt/trusted.gpg.d/microsoft.gpg
url: 'https://packages.microsoft.com/keys/microsoft.asc'
state: present
- name: Apt Repository
apt_repository:
repo: 'deb [arch=amd64] https://packages.microsoft.com/ubuntu/18.04/prod {{ ansible_distribution_release }} main'
state: present
mode: 0644
- name: Accept licenses
debconf:
name: "{{ item }}-installer"
question: "{{ item }}/accept_eula"
value: "true"
vtype: "select"
with_items:
- mssql-tools
- name: Install Packages
apt:
pkg: '{{ packages }}'
state: present
update_cache: yes
vars:
packages:
- mssql-tools
- unixodbc-dev
notify:
- Restart Apache
- name: PHP | Install PECL packages
shell: pecl install --soft {{ item }}
with_items:
- sqlsrv
- pdo_sqlsrv
when: false
- name: Configuration files
copy:
content: extension={{ item }}.so
dest: /etc/{{ php_base_dir }}/{{ php_conf_dir }}/{{ item }}.ini
owner: root
group: root
mode: 0644
with_items:
- sqlsrv
- pdo_sqlsrv
notify:
- Restart Apache
when: false
- name: Enable extensions
shell: phpenmod {{ item }}
with_items:
- sqlsrv
- pdo_sqlsrv
notify:
- Restart Apache
when: false
---
# file: roles/php/tasks/oci-5.3.yml
#
# @see OCI8 Install: https://help.ubuntu.com/community/PHPOracle
# Better:
# @see PDO_OCI Install: https://drupal.org/comment/5572626#comment-5572626
- name: PHP | Check OCI Requirement
stat:
path: /usr/lib/php5/20090626/pdo_oci.so
register: oci_file
- block:
- name: PHP | OCI | Enable OCI for PHP
copy:
content: extension={{ item }}.so
dest: /etc/{{ php_base_dir }}/{{ php_conf_dir }}/{{ item }}.ini
owner: root
group: root
mode: 0644
with_items:
- oci8
- pdo_oci
- name: PHP | OCI | Remove possible components in /tmp
file:
path: /tmp/{{ item }}
state: absent
with_items:
- instantclient_11_2
- oracle_x64_11_2_0_3_0_oci8_so
- oracle_x64_11_2_0_3_0_pdo_oci_so
- name: PHP | OCI | Make available Oracle InstantClient
command: scp -r {{ repository }}{{ item }} /tmp/
become: no
with_items:
- instantclient_11_2
- oracle_x64_11_2_0_3_0_oci8_so
- oracle_x64_11_2_0_3_0_pdo_oci_so
- name: PHP | OCI | Remove /usr/local/lib/instantclient_11_2
file:
path: /usr/local/lib/instantclient_11_2
state: absent
- name: PHP | OCI | Move Oracle InstantClient to /usr/local/lib
command: mv /tmp/instantclient_11_2 /usr/local/lib/
- name: PHP | OCI | Move oci8 to /usr/lib/php5
command: mv /tmp/oracle_x64_11_2_0_3_0_oci8_so /usr/lib/php5/20090626/oci8.so
- name: PHP | OCI | Move pdo_oci to /usr/lib/php5
command: mv /tmp/oracle_x64_11_2_0_3_0_pdo_oci_so /usr/lib/php5/20090626/pdo_oci.so
- name: PHP | OCI | Change ownership for Oracle InstantClient
file:
path: '{{ item }}'
owner: root
group: root
recurse: yes
follow: no
with_items:
- /usr/local/lib/instantclient_11_2
- name: Ensure log directories
file:
path: /usr/local/lib/instantclient_11_2/log/diag/clients
owner: www-data
group: root
state: directory
mode: 0775
follow: no
- name: Set permissions in log directories
file:
path: /usr/local/lib/instantclient_11_2/log
owner: www-data
group: root
mode: 0775
recurse: yes
follow: no
- name: PHP | OCI | Make available libclntsh.so
file:
src: /usr/local/lib/instantclient_11_2/libclntsh.so.11.1
dest: /usr/local/lib/instantclient_11_2/libclntsh.so
state: link
when: not oci_file.stat.exists
---
# file: roles/php/tasks/oci-5.5.yml
- debug: msg="OCI8 for PHP 5.5 not implemented yet"
---
# file: roles/php/tasks/oci-5.6.yml
- name: Check OCI Requirement
stat:
path: /usr/lib/php/20131226/oci8.so
register: oci_file
- block:
- name: Enable OCI for PHP
copy:
content: extension={{ item }}.so
dest: /etc/{{ php_base_dir }}/{{ php_conf_dir }}/{{ item }}.ini
owner: root
group: root
mode: 0644
with_items:
- oci8
- name: Remove possible components in /tmp
file:
path: /tmp/{{ item }}
state: absent
with_items:
- instantclient_11_2
- oracle_x64_11_2_0_3_0_oci8_so_php_5_6
- name: Make available Oracle InstantClient
command: scp -r {{ repository }}{{ item }} /tmp/
become: no
with_items:
- instantclient_11_2
- oracle_x64_11_2_0_3_0_oci8_so_php_5_6
- name: Remove /usr/local/lib/instantclient_11_2
file:
path: /usr/local/lib/instantclient_11_2
state: absent
- name: Move Oracle InstantClient to /usr/local/lib
command: mv /tmp/instantclient_11_2 /usr/local/lib/
- name: Move oci8 to /usr/lib/php
command: mv /tmp/oracle_x64_11_2_0_3_0_oci8_so_php_4_5 /usr/lib/php/20131226/oci8.so
- name: Change ownership for Oracle InstantClient
file:
path: '{{ item }}'
owner: root
group: root
recurse: yes
follow: no
with_items:
- /usr/local/lib/instantclient_11_2
- name: Ensure log directories
file:
path: /usr/local/lib/instantclient_11_2/log/diag/clients
owner: www-data
group: root
state: directory
mode: 0775
follow: no
- name: Set permissions in log directories
file:
path: /usr/local/lib/instantclient_11_2/log
owner: www-data
group: root
mode: 0775
recurse: yes
follow: no
- name: Make available libclntsh.so
file:
src: /usr/local/lib/instantclient_11_2/libclntsh.so.11.1
dest: /usr/local/lib/instantclient_11_2/libclntsh.so
state: link
when: not oci_file.stat.exists
---
# file: roles/php/tasks/oci-7.0.yml
- name: Check OCI Requirement
stat:
path: /usr/lib/php/20151012/oci8.so
register: oci_file
- block:
- name: Enable OCI for PHP
copy:
content: extension={{ item }}.so
dest: /etc/{{ php_base_dir }}/{{ php_conf_dir }}/{{ item }}.ini
owner: root
group: root
mode: 0644
with_items:
- oci8
- name: Remove possible components in /tmp
file:
path: /tmp/{{ item }}
state: absent
with_items:
- instantclient_11_2
- oracle_x64_11_2_0_3_0_oci8_so_php_7
- name: Make available Oracle InstantClient
command: scp -r {{ repository }}{{ item }} /tmp/
become: no
with_items:
- instantclient_11_2
- oracle_x64_11_2_0_3_0_oci8_so_php_7
- name: Remove /usr/local/lib/instantclient_11_2
file:
path: /usr/local/lib/instantclient_11_2
state: absent
- name: Move Oracle InstantClient to /usr/local/lib
command: mv /tmp/instantclient_11_2 /usr/local/lib/
- name: Move oci8 to /usr/lib/php
command: mv /tmp/oracle_x64_11_2_0_3_0_oci8_so_php_7 /usr/lib/php/20151012/oci8.so
- name: Change ownership for Oracle InstantClient
file:
path: '{{ item }}'
owner: root
group: root
recurse: yes
follow: no
with_items:
- /usr/local/lib/instantclient_11_2
- name: Ensure log directories
file:
path: /usr/local/lib/instantclient_11_2/log/diag/clients
owner: www-data
group: root
state: directory
mode: 0775
follow: no
- name: Set permissions in log directories
file:
path: /usr/local/lib/instantclient_11_2/log
owner: www-data
group: root
mode: 0775
recurse: yes
follow: no
- name: Make available libclntsh.so
file:
src: /usr/local/lib/instantclient_11_2/libclntsh.so.11.1
dest: /usr/local/lib/instantclient_11_2/libclntsh.so
state: link
when: not oci_file.stat.exists
---
# file: roles/php/tasks/oci-7.1.yml
- debug: msg="OCI8 for PHP 7.1 not implemented yet"
---
# file: roles/php/tasks/oci-7.2.yml
#
# https://gist.github.com/Yukibashiri/cebaeaccbe531665a5704b1b34a3498e
- name: Check OCI Requirement
stat:
path: /usr/lib/php/20170718/oci8.so
register: oci_file
- block:
- name: Enable OCI for PHP
copy:
content: extension={{ item }}.so
dest: /etc/{{ php_base_dir }}/{{ php_conf_dir }}/{{ item }}.ini
owner: root
group: root
mode: 0644
with_items:
- oci8
- name: Remove possible components in /tmp
file:
path: /tmp/{{ item }}
state: absent
with_items:
- instantclient_18_5
- oracle_x64_18_5_0_0_0_oci8_so_php_7
- name: Make available Oracle InstantClient
command: scp -r {{ repository }}{{ item }} /tmp/
become: no
with_items:
- instantclient_18_5
- oracle_x64_18_5_0_0_0_oci8_so_php_7
- name: Remove /opt/oracle/instantclient_18_5
file:
path: /opt/oracle/instantclient_18_5
state: absent
- name: Ensure directory /opt/oracle
file:
path: /opt/oracle
state: directory
- name: Move Oracle InstantClient to /opt/oracle
command: mv /tmp/instantclient_18_5 /opt/oracle/instantclient_18_5
- name: Move oci8 to /usr/lib/php
command: mv /tmp/oracle_x64_18_5_0_0_0_oci8_so_php_7 /usr/lib/php/20170718/oci8.so
- name: Change ownership for Oracle InstantClient
file:
path: '{{ item }}'
owner: root
group: root
recurse: yes
follow: no
with_items:
- /opt/oracle/instantclient_18_5
- name: Ensure log directories
file:
path: /opt/oracle/instantclient_18_5/log/diag/clients
owner: www-data
group: root
state: directory
mode: 0775
follow: no
- name: Set permissions in log directories
file:
path: /opt/oracle/instantclient_18_5/log
owner: www-data
group: root
mode: 0775
recurse: yes
follow: no
- name: Create symlinks
file:
src: /opt/oracle/instantclient_18_5/{{ item }}.so.18.1
dest: /opt/oracle/instantclient_18_5/{{ item }}.so
state: link
with_items:
- libclntsh
- libocci
- name: Configure libraries
template:
src: etc-ld-oracle
dest: /etc/ld.so.conf.d/oracle-instantclient.conf
owner: root
group: root
mode: 0644
- name: Update libraries
command: ldconfig
when: not oci_file.stat.exists
---
# file: roles/php/tasks/oci-7.3.yml
- debug: msg="OCI8 for PHP 7.3 not implemented yet"
---
# file: roles/php/tasks/oci-7.4.yml
#
# https://gist.github.com/Yukibashiri/cebaeaccbe531665a5704b1b34a3498e
- name: Check OCI Requirement
stat:
path: /usr/lib/php/20190902/oci8.so
register: oci_file
- block:
- name: Enable OCI for PHP
copy:
content: extension={{ item }}.so
dest: /etc/{{ php_base_dir }}/{{ php_conf_dir }}/{{ item }}.ini
owner: root
group: root
mode: 0644
with_items:
- oci8
- name: Remove possible components in /tmp
file:
path: /tmp/{{ item }}
state: absent
with_items:
- instantclient_18_5
- oracle_x64_18_5_0_0_0_oci8_so_php_7
- name: Make available Oracle InstantClient
command: scp -r {{ repository }}{{ item }} /tmp/
become: no
with_items:
- instantclient_18_5
- oracle_x64_18_5_0_0_0_oci8_so_php_7_4
- name: Remove /opt/oracle/instantclient_18_5
file:
path: /opt/oracle/instantclient_18_5
state: absent
- name: Ensure directory /opt/oracle
file:
path: /opt/oracle
state: directory
- name: Move Oracle InstantClient to /opt/oracle
command: mv /tmp/instantclient_18_5 /opt/oracle/instantclient_18_5
- name: Move oci8 to /usr/lib/php
command: mv /tmp/oracle_x64_18_5_0_0_0_oci8_so_php_7_4 /usr/lib/php/20190902/oci8.so
- name: Change ownership for Oracle InstantClient
file:
path: '{{ item }}'
owner: root
group: root
recurse: yes
follow: no
with_items:
- /opt/oracle/instantclient_18_5
- name: Ensure log directories
file:
path: /opt/oracle/instantclient_18_5/log/diag/clients
owner: www-data
group: root
state: directory
mode: 0775
follow: no
- name: Set permissions in log directories
file:
path: /opt/oracle/instantclient_18_5/log
owner: www-data
group: root
mode: 0775
recurse: yes
follow: no
- name: Create symlinks
file:
src: /opt/oracle/instantclient_18_5/{{ item }}.so.18.1
dest: /opt/oracle/instantclient_18_5/{{ item }}.so
state: link
with_items:
- libclntsh
- libocci
- name: Configure libraries
template:
src: etc-ld-oracle
dest: /etc/ld.so.conf.d/oracle-instantclient.conf
owner: root
group: root
mode: 0644
- name: Update libraries
command: ldconfig
when: not oci_file.stat.exists
---
# file: roles/php/tasks/oci8.yml
#
# @see OCI8 Install: https://help.ubuntu.com/community/PHPOracle
# Better:
# @see PDO_OCI Install: https://drupal.org/comment/5572626#comment-5572626
- name: "PHP | OCI | Enable OCI for PHP"
copy:
content='extension={{ item }}.so'
dest=/etc/php5/{{ php_conf_dir }}/{{ item }}.ini
owner=root
group=root
mode=0644
with_items:
- oci8
- pdo_oci
- name: "PHP | OCI | Remove possible components in /tmp"
command: rm -Rf /tmp/{{ item }}
with_items:
- instantclient_11_2
- oracle_x64_11_2_0_3_0_oci8_so
- oracle_x64_11_2_0_3_0_pdo_oci_so
- name: "PHP | OCI | Make available Oracle InstantClient"
command: scp -r {{ repository }}{{ item }} /tmp/
sudo: no
with_items:
- instantclient_11_2
- oracle_x64_11_2_0_3_0_oci8_so
- oracle_x64_11_2_0_3_0_pdo_oci_so
- name: "PHP | OCI | Remove /usr/local/lib/instantclient_11_2"
command: rm -Rf /usr/local/lib/instantclient_11_2
- name: "PHP | OCI | Move Oracle InstantClient to /usr/local/lib"
command: mv /tmp/instantclient_11_2 /usr/local/lib/
- name: "PHP | OCI | Move oci8 to /usr/lib/php5"
command: mv /tmp/oracle_x64_11_2_0_3_0_oci8_so /usr/lib/php5/20090626/oci8.so
- name: "PHP | OCI | Move pdo_oci to /usr/lib/php5"
command: mv /tmp/oracle_x64_11_2_0_3_0_pdo_oci_so /usr/lib/php5/20090626/pdo_oci.so
- name: "PHP | OCI | Change ownership for Oracle InstantClient"
command: chown -R root:root {{ item }}
with_items:
- /usr/local/lib/instantclient_11_2
- /usr/lib/php5/20090626/oci8.so
- /usr/lib/php5/20090626/pdo_oci.so
- name: "PHP | OCI | Make available libclntsh.so"
file:
src=/usr/local/lib/instantclient_11_2/libclntsh.so.11.1
dest=/usr/local/lib/instantclient_11_2/libclntsh.so
state=link
---
# file: roles/php/tasks/php.yml
- name: "PHP | Install required packages."
- name: Apt Repository
apt_repository:
repo: '{{ item }}'
state: present
mode: 0644
with_items: '{{ php_repositories }}'
- name: Install required packages.
apt:
pkg={{ item }}
state=installed
with_items:
- php5
- php-apc
- php-soap
- php5-mysql
- php5-xmlrpc
- php5-gd
- php5-mcrypt
- php5-imap
- php5-curl
- php5-xdebug
- php5-dev
- php-pear
# TODO: Upgrade APCu on Ubuntu 14.04
# @see https://github.com/owncloud/core/issues/14175#issuecomment-74573088
# wget https://launchpad.net/~ondrej/+archive/ubuntu/php5/+build/6149263/+files/php5-apcu_4.0.6-1%2Bdeb.sury.org~utopic%2B1_amd64.deb
# sudo dpkg -i php5-apcu_4.0.6-1+deb.sury.org~utopic+1_amd64.deb
- name: "PHP | Configuration file, php.ini"
pkg: '{{ php_packages }}'
state: present
force: yes
notify:
- Restart Apache
- name: Hold em all
shell: dpkg --get-selections | grep ^sed s/install/hold/g | sudo dpkg --set-selections
when: php_hold_version
- name: Install PECL packages
shell: pecl install --soft imagick-3.3.0
when: php_version_main|default(7) != 7
ignore_errors: yes
# NOTE: If oauth is already installed and we install a new PHP 7 version then this fails and we need --force as well
- name: Install PECL packages
shell: pecl install --soft --force oauth
when: php_version_main|default(7) == 7
ignore_errors: yes
- name: Ensure Apache config directory
file:
dest: /etc/{{ php_base_dir }}/apache2
state: directory
owner: root
group: root
mode: 0755
- name: Configuration file, php.ini
template:
src=etc-php5-apache2-php.ini
dest=/etc/php5/apache2/php.ini
owner=root
group=root
mode=0644
src: etc-php5-apache2-php.ini
dest: /etc/{{ php_base_dir }}/apache2/php.ini
owner: root
group: root
mode: 0644
notify:
- Restart Apache
- name: "PHP | Cache configuration file, apc.ini"
- name: Import php53
import_tasks: php53.yml
when: php_version|default('5.5') == '5.3'
- name: Configuration file, fcgid.conf
template:
src=etc-php5-conf-d-apc.ini
dest=/etc/php5/{{ php_conf_dir }}/apc.ini
owner=root
group=root
mode=0644
src: fcgid.conf
dest: /etc/apache2/mods-available/fcgid.conf
owner: root
group: root
mode: 0644
notify:
- Restart Apache
- name: "PHP | Create extra directory for browscap"
- name: Configuration files
template:
src: etc-php5-conf-d-{{ item }}.ini
dest: /etc/{{ php_base_dir }}/{{ php_conf_dir }}/{{ item }}.ini
owner: root
group: root
mode: 0644
with_items:
- apcu
- opcache
notify:
- Restart Apache
- name: Create extra directory for browscap
file:
dest=/etc/php5/apache2/extra
state=directory
owner=root
group=root
dest: /etc/{{ php_base_dir }}/apache2/extra
state: directory
owner: root
group: root
when: php_browscap
- name: "PHP | browscap.ini"
- name: browscap.ini
copy:
src=browscap.ini
dest=/etc/php5/apache2/extra/browscap.ini
owner=root
group=root
src: browscap.ini
dest: /etc/{{ php_base_dir }}/apache2/extra/browscap.ini
owner: root
group: root
when: php_browscap
notify:
- Restart Apache
- name: "PHP | Enable PHP modules"
shell: php5enmod {{ item }}
with_items:
- mcrypt
- imap
when: php_conf_dir == 'mods-available'
- name: "PHP | Create htdocs directory for apc status"
- name: Create htdocs directory for apc status
file:
dest=/var/www/apc
state=directory
owner=www-data
group=www-data
dest: /var/www/apc
state: directory
owner: www-data
group: www-data
- name: "PHP | Copy APC status php script"
- name: Copy APC status php script
copy:
src=apc.php
dest=/var/www/apc
owner=www-data
group=www-data
- name: "PHP | Check OCI Requirement"
shell: ls /usr/lib/php5/20090626/pdo_oci.so
register: oci_available
when: php_needs_oci8
ignore_errors: yes
changed_when: oci_available.stdout != '/usr/lib/php5/20090626/pdo_oci.so'
src: apc.php
dest: /var/www/apc
owner: www-data
group: www-data
- name: Include oci version
include_tasks: oci-{{ php_version|default('5.5') }}.yml
when: repository is defined and php_needs_oci8
- name: Include mcrypt
include_tasks: mcrypt-7.2.yml
when: php_version|default('5.5') == '7.2' and php_needs_mcrypt
- name: Import msodbc
import_tasks: msodbc.yml
when: php_needs_msodbc
- block:
- name: Apache FPM Socket Configuration
template:
src: etc-apache2-conf-available-php-fpm
dest: /etc/apache2/{{ apache_conf_dir }}/php{{ php_version_main }}-fpm.conf
owner: root
group: root
mode: 0644
notify:
- Restart Apache
- name: Enable Apache PHP FPM Configuration
command: a2enconf php{{ php_version_main }}-fpm
args:
creates: /etc/apache2/conf-enabled/php{{ php_version_main }}-fpm{{ apache_conf_ext }}
notify:
- Restart Apache
when: php_fpm_socket
- name: FPM Default Pool Configuration
template:
src: php_pool.conf
dest: /etc/{{ php_base_dir }}/fpm/pool.d/default.conf
owner: root
group: root
mode: 0644
when: (php_version_main|default(7) == 7) and php_fpm and apache_server_default
notify:
- Restart PHP-FPM
- block:
- name: Set facts for PHP 7
set_fact:
phpLogRotatePrefix: '{{php_version|default("7.0")}}'
phpLibPrefix: ''
when: php_version_main|default(7) == 7
- name: Set facts for PHP 5
set_fact:
phpLogRotatePrefix: '5'
phpLibPrefix: '5'
when: php_version_main|default(7) != 7
- name: Install logrotate script
template:
src: etc-logrotate-php
dest: /etc/logrotate.d/php{{ phpLogRotatePrefix }}-fpm
owner: root
group: root
mode: 0644
notify:
- Initial Logrotate
- name: Adjust apache config for default site
lineinfile:
dest: /etc/apache2/sites-available/{{ apache_conf_default_prefix }}default{{ apache_conf_ext }}
regexp: '{{ item.regexp }}'
line: '{{ item.line }}'
backrefs: yes
with_items:
- regexp: 'ProxyPassMatch'
line: ' ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:{{ php_fpm_port|default(9999) }}/var/www{{apache_server_default_root}}/$1'
- regexp: '<Proxy fcgi'
line: ' <Proxy fcgi://127.0.0.1:{{ php_fpm_port|default(9999) }}>'
when: apache_server_default
notify:
- Restart PHP-FPM
- Restart Apache
when: php_fpm
tags:
- logrotate
- include: oci.yml
when: repository is defined and php_needs_oci8 and oci_available.stdout != '/usr/lib/php5/20090626/pdo_oci.so'
- name: Explicitly set PHP version for CLI
alternatives:
name: php
path: /usr/bin/php{{ php_version }}
# see https://www.howtoforge.com/how-to-use-multiple-php-versions-php-fpm-and-fastcgi-with-ispconfig-3-ubuntu-12.10
---
# file: roles/php/tasks/php53.yml
- name: Ensure PHP53 config directory
file:
dest: '{{ item }}'
state: directory
with_items:
- /etc/{{ php_base_dir }}/fpm/pool.d/
- name: Check PHP 5.3 Requirement
shell: php --version
register: php_version_available
changed_when: no
- block:
- name: Package Preferences
template:
src: preferences/{{ item }}
dest: /etc/apt/preferences.d/{{ item }}-pin
owner: root
group: root
mode: 0644
with_items:
- openssl
- libssl
- name: Install Packages
apt:
pkg: '{{ packages }}'
state: present
vars:
packages:
- autoconf2.13
- automake1.4
- build-essential
- libc-client2007e
- libc-client2007e-dev
- libfcgi-dev
- libfcgi0ldbl
- libfreetype6-dev
- libgif-dev
- libgif4
- libjpeg-progs
- libjpeg62-dbg
- libjpeg8
- libjpeg8-dev
- libmcrypt-dev
- libmysqlclient-dev
- libpcre++-dev
- libpcre3-dev
- libpng-dev
- libssl-dev
- libx11-dev
- libxau-dev
- libxcb1-dev
- libxdmcp-dev
- libxml2-dev
- libxml2-dev
- libxpm-dev
- x11proto-core-dev
- x11proto-input-dev
- x11proto-kb-dev
- xtrans-dev
- name: Link Client Lib
file:
src: /usr/lib/libc-client.a
dest: /usr/lib/x86_64-linux-gnu/libc-client.a
state: link
- name: Make sure an empty directory /tmp/php53 exists
file:
path: /tmp/php53
state: '{{ item }}'
with_items:
- absent
- directory
- name: Download PHP 5.3
get_url:
url: 'http://in1.php.net/distributions/php-5.3.29.tar.bz2'
dest: /tmp/php-5.3.29.tar.bz2
- name: Unpack PHP 5.3
unarchive:
src: /tmp/php-5.3.29.tar.bz2
dest: /tmp/php53
copy: no
- name: Compile PHP 5.3
shell: '{{ item }}'
args:
chdir: /tmp/php53/php-5.3.29
with_items:
- ./configure --with-libdir=/lib/x86_64-linux-gnu --enable-fpm --enable-mbstring --enable-sockets --with-zlib --enable-zip --with-imap-ssl --with-imap --with-curl --with-mcrypt --with-gd --with-mysql --with-pdo-mysql --with-mysqli --with-gettext --with-jpeg-dir=/usr --with-png-dir=/usr --with-kerberos --with-openssl --disable-cgi
- make
- make install
- name: Create PHP53 Start Script
template:
src: etc-init-d-php53-fpm
dest: /etc/init.d/php-fpm
owner: root
group: root
mode: 0755
- name: Add PHP-FPM to Boot-List
command: update-rc.d php-fpm defaults
when: php_version_available and 'PHP 5.3.29' not in php_version_available.stdout
- name: Copy PHP53 Libraries
copy:
src: php53/libs/{{ item.file }}
dest: '{{ php53.libdir }}/{{ item.file }}'
owner: root
group: root
mode: 0644
with_items: '{{ php53.libraries }}'
- name: Ensure PHP53 Library Links
file:
src: '{{ php53.libdir }}/{{ item.file }}'
dest: '{{ php53.libdir }}/{{ item.link }}'
state: link
owner: root
group: root
mode: 0644
with_items: '{{ php53.libraries }}'
- name: Ensure extra Library Links
file:
src: '{{ item.src }}'
dest: '{{ php53.libdir }}/{{ item.link }}'
state: link
owner: root
group: root
mode: 0644
with_items: '{{ php53.liblinks }}'
- name: Copy PHP53 Modules
copy:
src: php53/{{ item }}.so
dest: '{{ php53.extdir }}/{{ item }}.so'
owner: root
group: root
mode: 0644
with_items: '{{ php53.modules }}'
- name: Create PHP53 INI Files
template:
src: etc-php5-apache2-php.ini
dest: /etc/{{ php_base_dir }}/{{ item }}/php.ini
owner: root
group: root
mode: 0644
with_items:
- cgi53
- cli53
- fpm
---
# file: roles/php/tasks/variables.yml
- block:
- name: Set default facts
set_fact:
phpFpmService: php5-fpm
- name: Set facts for PHP 5
set_fact:
phpFpmService: php-fpm
when: php_version_main|default(7) == 5
- name: Set facts for PHP 7
set_fact:
phpFpmService: php{{php_version|default("7.0")}}-fpm
when: php_version_main|default(7) == 7
tags:
- always
<IfModule mod_fastcgi.c>
AddHandler php{{ php_version_main }}-fcgi .php
Action php{{ php_version_main }}-fcgi /php{{ php_version_main }}-fcgi
Alias /php{{ php_version_main }}-fcgi /usr/lib/cgi-bin/php{{ php_version_main }}-fcgi
FastCgiExternalServer /usr/lib/cgi-bin/php{{ php_version_main }}-fcgi -socket /var/run/php{{ php_version_main }}-fpm.sock -pass-header Authorization
<Directory /usr/lib/cgi-bin>
Include /etc/apache2/{{ apache_conf_dir }}/global-deny.conf
</Directory>
</IfModule>
#!/bin/sh
### BEGIN INIT INFO
# Provides: php-fpm
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts php-fpm
# Description: starts the PHP FastCGI Process Manager daemon
### END INIT INFO
prefix=/usr/local
exec_prefix=${prefix}
php_fpm_BIN=${exec_prefix}/sbin/php-fpm
php_fpm_CONF=/etc/{{ php_base_dir }}/fpm/php-fpm.conf
php_fpm_INI=/etc/{{ php_base_dir }}/fpm/php.ini
php_fpm_PID=/var/run/php5-fpm.pid
php_opts="-c $php_fpm_INI --fpm-config $php_fpm_CONF --pid $php_fpm_PID"
wait_for_pid () {
try=0
while test $try -lt 35 ; do
case "$1" in
'created')
if [ -f "$2" ] ; then
try=''
break
fi
;;
'removed')
if [ ! -f "$2" ] ; then
try=''
break
fi
;;
esac
echo -n .
try=`expr $try + 1`
sleep 1
done
}
case "$1" in
start)
echo -n "Starting php-fpm "
$php_fpm_BIN --daemonize $php_opts
if [ "$?" != 0 ] ; then
echo " failed"
exit 1
fi
wait_for_pid created $php_fpm_PID
if [ -n "$try" ] ; then
echo " failed"
exit 1
else
echo " done"
fi
;;
stop)
echo -n "Gracefully shutting down php-fpm "
if [ ! -r $php_fpm_PID ] ; then
echo "warning, no pid file found - php-fpm is not running ?"
exit 1
fi
kill -QUIT `cat $php_fpm_PID`
wait_for_pid removed $php_fpm_PID
if [ -n "$try" ] ; then
echo " failed. Use force-quit"
exit 1
else
echo " done"
fi
;;
force-quit)
echo -n "Terminating php-fpm "
if [ ! -r $php_fpm_PID ] ; then
echo "warning, no pid file found - php-fpm is not running ?"
exit 1
fi
kill -TERM `cat $php_fpm_PID`
wait_for_pid removed $php_fpm_PID
if [ -n "$try" ] ; then
echo " failed"
exit 1
else
echo " done"
fi
;;
restart)
$0 stop
$0 start
;;
reload)
echo -n "Reload service php-fpm "
if [ ! -r $php_fpm_PID ] ; then
echo "warning, no pid file found - php-fpm is not running ?"
exit 1
fi
kill -USR2 `cat $php_fpm_PID`
echo " done"
;;
*)
echo "Usage: $0 {start|stop|force-quit|restart|reload}"
exit 1
;;
esac
/opt/oracle/instantclient_18_5