mirror of
https://github.com/HanXHX/ansible-php.git
synced 2026-02-28 09:42:09 +07:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e53b9cd80 | ||
|
|
cbceba6897 | ||
|
|
d836862837 | ||
|
|
df8b58b46a | ||
|
|
de41097cde | ||
|
|
71721d1afc | ||
|
|
3d7c68e700 | ||
|
|
6d4a7e1a08 |
@@ -30,8 +30,8 @@ services:
|
||||
- docker
|
||||
|
||||
before_install:
|
||||
- wget https://releases.hashicorp.com/vagrant/1.9.5/vagrant_1.9.5_x86_64.deb
|
||||
- sudo dpkg -i vagrant_1.9.5_x86_64.deb
|
||||
- wget https://releases.hashicorp.com/vagrant/2.0.1/vagrant_2.0.1_x86_64.deb
|
||||
- sudo dpkg -i vagrant_2.0.1_x86_64.deb
|
||||
|
||||
install:
|
||||
- pip install "$ANSIBLE_VERSION"
|
||||
|
||||
24
README.md
24
README.md
@@ -8,10 +8,14 @@ Install PHP (php-fpm optional) on Debian. Manage APCu, Opcache, Xdebug.
|
||||
Managed OS / Versions
|
||||
---------------------
|
||||
|
||||
| OS | PHP 5.6 | PHP 7.0 | PHP 7.1 |
|
||||
|:-------------: |:-----------------: |:-------------------------: |:-------------------------: |
|
||||
| Debian Jessie | Yes (from Debian) | Yes (from [Dotdeb](https://www.dotdeb.org) or [Sury](https://deb.sury.org/)) | Yes (from [Dotdeb](https://www.dotdeb.org) or [Sury](https://deb.sury.org/)) |
|
||||
| Debian Strech | No | Yes (from Debian) | Yes (from [Sury](https://deb.sury.org/)) |
|
||||
| OS | PHP 5.6 | PHP 7.0 | PHP 7.1 | PHP 7.2 |
|
||||
|:-------------:|:---------:|:-------------------------:|:---------------------:|:------------:|
|
||||
| Debian Jessie | Yes | Yes (from Dotdeb or Sury) | Yes (Dotdeb or Sury) | Yes (Sury) |
|
||||
| Debian Strech | No | Yes | Yes (Sury) | Yes (Sury) |
|
||||
|
||||
Links:
|
||||
- [Dotdeb](https://www.dotdeb.org)
|
||||
- [Sury](https://deb.sury.org/)
|
||||
|
||||
Requirements
|
||||
------------
|
||||
@@ -159,6 +163,18 @@ License
|
||||
|
||||
GPLv2
|
||||
|
||||
Donation
|
||||
--------
|
||||
|
||||
If this code helped you, or if you’ve used them for your projects, feel free to buy me some :beers:
|
||||
|
||||
- Bitcoin: `1BQwhBeszzWbUTyK4aUyq3SRg7rBSHcEQn`
|
||||
- Ethereum: `63abe6b2648fd892816d87a31e3d9d4365a737b5`
|
||||
- Litecoin: `LeNDw34zQLX84VvhCGADNvHMEgb5QyFXyD`
|
||||
- Monero: `45wbf7VdQAZS5EWUrPhen7Wo4hy7Pa7c7ZBdaWQSRowtd3CZ5vpVw5nTPphTuqVQrnYZC72FXDYyfP31uJmfSQ6qRXFy3bQ`
|
||||
|
||||
No crypto-currency? :star: the project is also a way of saying thank you! :sunglasses:
|
||||
|
||||
Author Information
|
||||
------------------
|
||||
|
||||
|
||||
4
Vagrantfile
vendored
4
Vagrantfile
vendored
@@ -33,7 +33,7 @@ Vagrant.configure("2") do |config|
|
||||
m.vm.provision "ansible" do |ansible|
|
||||
ansible.playbook = "tests/test.yml"
|
||||
ansible.verbose = 'vv'
|
||||
ansible.sudo = true
|
||||
ansible.become = true
|
||||
ansible.extra_vars = opts[:vars]
|
||||
end
|
||||
end
|
||||
@@ -49,7 +49,7 @@ Vagrant.configure("2") do |config|
|
||||
m.vm.provision "ansible" do |ansible|
|
||||
ansible.playbook = "tests/test.yml"
|
||||
ansible.verbose = 'vv'
|
||||
ansible.sudo = true
|
||||
ansible.become = true
|
||||
ansible.extra_vars = opts[:vars]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,14 +7,11 @@ php_extra_packages: []
|
||||
|
||||
# php.ini config
|
||||
php_ini:
|
||||
- key: 'date.timezone'
|
||||
value: 'Europe/Paris'
|
||||
- key: 'expose_php'
|
||||
value: 'Off'
|
||||
- key: 'memory_limit'
|
||||
value: '256M'
|
||||
php_ini_fpm: []
|
||||
php_ini_cli: []
|
||||
'date.timezone': 'Europe/Paris'
|
||||
'expose_php': 'Off'
|
||||
'memory_limit': '256M'
|
||||
php_ini_fpm: {}
|
||||
php_ini_cli: {}
|
||||
|
||||
# OpCache settings
|
||||
php_opcache_enable: "1"
|
||||
|
||||
@@ -16,8 +16,6 @@ galaxy_info:
|
||||
- php5.6
|
||||
- php5
|
||||
- php7
|
||||
- php7.0
|
||||
- php7.1
|
||||
- debian
|
||||
dependencies: []
|
||||
|
||||
|
||||
@@ -4,13 +4,11 @@
|
||||
apt: pkg={{ php_fpm_service }} state=present
|
||||
|
||||
- name: LINEINFILE | PHP configuration
|
||||
lineinfile: >
|
||||
dest='{{ php_etc_dir }}/fpm/php.ini'
|
||||
regexp='^;?{{ item.key }}'
|
||||
line='{{ item.key }} = {{ item.value }}'
|
||||
with_flattened:
|
||||
- "{{ php_ini }}"
|
||||
- "{{ php_ini_fpm }}"
|
||||
lineinfile:
|
||||
dest: '{{ php_etc_dir }}/fpm/php.ini'
|
||||
regexp: '^;?{{ item.key }}'
|
||||
line: '{{ item.key }} = {{ item.value }}'
|
||||
with_dict: "{{ php_ini | combine(php_ini_fpm) }}"
|
||||
notify: restart php-fpm
|
||||
|
||||
- name: TEMPLATE | Deploy pool configuration
|
||||
|
||||
@@ -26,18 +26,14 @@
|
||||
when: php_install_fpm
|
||||
|
||||
- name: LINEINFILE | PHP configuration
|
||||
lineinfile: >
|
||||
dest='{{ php_etc_dir }}/cli/php.ini'
|
||||
regexp='^;?{{ item.key }}'
|
||||
line='{{ item.key }} = {{ item.value }}'
|
||||
with_flattened:
|
||||
- "{{ php_ini }}"
|
||||
- "{{ php_ini_cli }}"
|
||||
lineinfile:
|
||||
dest: '{{ php_etc_dir }}/cli/php.ini'
|
||||
regexp: '^;?{{ item.key }}'
|
||||
line: '{{ item.key }} = {{ item.value }}'
|
||||
with_dict: "{{ php_ini_cli }}"
|
||||
|
||||
- name: INCLUDE | Xdebug
|
||||
include: xdebug.yml
|
||||
when: php_install_xdebug
|
||||
|
||||
- name: APT | Install and configure opcache
|
||||
include: opcache.yml
|
||||
|
||||
|
||||
@@ -1,21 +1,38 @@
|
||||
---
|
||||
|
||||
- name: APT | Install php-xdebug
|
||||
apt: >
|
||||
pkg="{{ php_apt_prefix }}xdebug"
|
||||
state=present
|
||||
update_cache=yes
|
||||
cache_valid_time=3600
|
||||
- block:
|
||||
|
||||
- name: SHELL | Get Xdebug version
|
||||
shell: dpkg -l | awk '$2 ~ /xdebug$/ { print $3 }'
|
||||
changed_when: false
|
||||
register: xdebug_version
|
||||
- name: APT | Install php-xdebug
|
||||
apt:
|
||||
pkg: "{{ php_apt_prefix }}xdebug"
|
||||
state: present
|
||||
update_cache: yes
|
||||
cache_valid_time: 3600
|
||||
|
||||
- name: TEMPLATE | Deploy module configurations
|
||||
template: >
|
||||
src=etc/__php__/mods-available/xdebug.ini.j2
|
||||
dest={{ php_mods_dir }}/xdebug.ini
|
||||
owner=root
|
||||
mode=0644
|
||||
notify: restart php-fpm
|
||||
- name: SHELL | Get Xdebug version
|
||||
shell: dpkg -l | awk '$2 ~ /xdebug$/ { print $3 }'
|
||||
changed_when: false
|
||||
register: xdebug_version
|
||||
|
||||
- name: TEMPLATE | Deploy module configurations
|
||||
template:
|
||||
src: "etc/__php__/mods-available/xdebug.ini.j2"
|
||||
dest: "{{ php_mods_dir }}/xdebug.ini"
|
||||
owner: root
|
||||
mode: 0644
|
||||
notify: restart php-fpm
|
||||
|
||||
when: php_install_xdebug
|
||||
|
||||
- block:
|
||||
|
||||
# We can't uninstall as simple way. We can uninstall with php7.0-xdebug (virtual package), but removing virtual package doesn't affect real package.
|
||||
# On Jessie: php5-xdebug, php-xdebug (sury for PHP 5.6/7.0/7.1/7.2), php5-xdebug + php7.0-xdebug (dotdeb)
|
||||
# On Stretch: php-xdebug
|
||||
|
||||
- name: COMMAND | Disable xdebug package
|
||||
command: phpdismod -v {{ php_version }} xdebug
|
||||
args:
|
||||
removes: "{{ php_etc_dir }}/cli/conf.d/20-xdebug.ini"
|
||||
|
||||
when: not php_install_xdebug
|
||||
|
||||
@@ -231,7 +231,11 @@ pm.max_spare_servers = {{ item.pm_max_spare_servers }}
|
||||
; anything, but it may not be a good idea to use the .php extension or it
|
||||
; may conflict with a real PHP file.
|
||||
; Default Value: not set
|
||||
;pm.status_path = /status
|
||||
{% if item.status_path is defined %}
|
||||
pm.status_path = {{ item.status_path }}
|
||||
{% else %}
|
||||
;pm.status.path = /status
|
||||
{% endif %}
|
||||
|
||||
; The ping URI to call the monitoring page of FPM. If this value is not set, no
|
||||
; URI will be recognized as a ping page. This could be used to test from outside
|
||||
@@ -243,12 +247,20 @@ pm.max_spare_servers = {{ item.pm_max_spare_servers }}
|
||||
; anything, but it may not be a good idea to use the .php extension or it
|
||||
; may conflict with a real PHP file.
|
||||
; Default Value: not set
|
||||
{% if item.ping_path is defined %}
|
||||
ping.path = {{ item.ping_path }}
|
||||
{% else %}
|
||||
;ping.path = /ping
|
||||
{% endif %}
|
||||
|
||||
; This directive may be used to customize the response of a ping request. The
|
||||
; response is formatted as text/plain with a 200 response code.
|
||||
; Default Value: pong
|
||||
{% if item.ping_response is defined %}
|
||||
ping.response = {{ item.ping_response }}
|
||||
{% else %}
|
||||
;ping.response = pong
|
||||
{% endif %}
|
||||
|
||||
; The access log file
|
||||
; Default: not set
|
||||
|
||||
23
tests/templates/site.j2
Normal file
23
tests/templates/site.j2
Normal file
@@ -0,0 +1,23 @@
|
||||
server {
|
||||
server_name {{ vhost }};
|
||||
|
||||
root /var/www;
|
||||
|
||||
{% if php_fpm_poold.0.status_path is defined %}
|
||||
location = {{ php_fpm_poold.0.status_path }} {
|
||||
include {{ nginx_include }};
|
||||
fastcgi_pass unix:{{ php_default_fpm_sock }};
|
||||
}
|
||||
{% endif %}
|
||||
{% if php_fpm_poold.0.ping_path is defined %}
|
||||
location = {{ php_fpm_poold.0.ping_path }} {
|
||||
include {{ nginx_include }};
|
||||
fastcgi_pass unix:{{ php_default_fpm_sock }};
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
location ~ \.php$ {
|
||||
include {{ nginx_include }};
|
||||
fastcgi_pass unix:{{ php_default_fpm_sock }};
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,21 @@
|
||||
php_extra_packages:
|
||||
- '{{ php_apt_prefix }}recode'
|
||||
php_install_xdebug: true
|
||||
php_ini_fpm:
|
||||
display_errors: 'Off'
|
||||
php_ini_cli:
|
||||
error_reporting: 'E_ALL'
|
||||
php_fpm_poold:
|
||||
- pool_name: 'www'
|
||||
listen: '{{ php_default_fpm_sock }}'
|
||||
pm: 'dynamic'
|
||||
pm_max_children: 250
|
||||
pm_start_servers: 10
|
||||
pm_min_spare_servers: 10
|
||||
pm_max_spare_servers: 20
|
||||
status_path: '/status'
|
||||
ping_path: '/ping'
|
||||
ping_response: 'ok'
|
||||
|
||||
pre_tasks:
|
||||
|
||||
@@ -41,10 +56,16 @@
|
||||
|
||||
tasks:
|
||||
|
||||
- name: COPY | Vhost
|
||||
copy: >
|
||||
dest=/etc/nginx/sites-enabled/{{ vhost }}
|
||||
content='server { server_name {{ vhost }}; root /var/www; location ~ \.php$ { include {{ nginx_include }}; fastcgi_pass unix:{{ php_default_fpm_sock }}; } }'
|
||||
- name: TEMPLATE | Nginx site config
|
||||
template:
|
||||
src: templates/site.j2
|
||||
dest: /etc/nginx/sites-enabled/{{ vhost }}
|
||||
notify: reload nginx
|
||||
|
||||
- name: FILE | Delete default site
|
||||
file:
|
||||
path: /etc/nginx/sites-enabled/default
|
||||
state: absent
|
||||
notify: reload nginx
|
||||
|
||||
handlers:
|
||||
@@ -76,3 +97,13 @@
|
||||
changed_when: false
|
||||
register: c
|
||||
failed_when: c.stdout == ''
|
||||
|
||||
- name: URI | Check ping
|
||||
uri:
|
||||
url: "http://localhost{{ php_fpm_poold.0.ping_path }}"
|
||||
when: php_fpm_poold.0.ping_path is defined
|
||||
|
||||
- name: URI | Check status
|
||||
uri:
|
||||
url: "http://localhost{{ php_fpm_poold.0.status_path }}"
|
||||
when: php_fpm_poold.0.status_path is defined
|
||||
|
||||
@@ -3,3 +3,4 @@ php_managed_versions:
|
||||
- '5.6'
|
||||
- '7.0'
|
||||
- '7.1'
|
||||
- '7.2'
|
||||
|
||||
@@ -2,3 +2,4 @@ php_default_version: '7.0'
|
||||
php_managed_versions:
|
||||
- '7.0'
|
||||
- '7.1'
|
||||
- '7.2'
|
||||
|
||||
Reference in New Issue
Block a user