Skip to content

Commit 7e4a993

Browse files
committed
Initial revision
0 parents  commit 7e4a993

File tree

11 files changed

+2079
-0
lines changed

11 files changed

+2079
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.tags
2+

README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
php7-fpm Ansible playbook
2+
=========================
3+
4+
This playbook will install php7-fpm in Xenial (16.04)
5+
6+
Requirements
7+
------------
8+
9+
Required packages (installed automatically) :
10+
11+
- php7-fpm
12+
- php7.0-opcache
13+
- php-apcu
14+
- php7.0-mcrypt
15+
- php7.0-gd
16+
- php7.0-curl
17+
- php-pear
18+
- php7.0-mysql
19+
20+
Role Variables
21+
--------------
22+
23+
- `php7_memory_limit`: max memory per PHP process (default: 128M)
24+
- `php7_post_max_size`: max post size (default: 40M)
25+
- `php7_upload_max_filesize`: max upload size for files (default: 20M)
26+
27+
28+
Tags
29+
----
30+
31+
- `php7-fpm` : applies to the whole role
32+
33+
Dependencies
34+
------------
35+
36+
- git@github.com:leucos/ansible-nginx.git
37+
38+
Example Playbook
39+
----------------
40+
41+
This is mainly used as a dependency in your existing playbooks, like:
42+
43+
dependencies:
44+
- { role: ansible-php7-fpm }
45+
46+
but can be used in playbooks also :
47+
48+
- name: web servers
49+
hosts: webservers
50+
roles:
51+
- ansible-php7-fpm
52+
53+
License
54+
-------
55+
56+
MIT
57+
58+
Author Information
59+
------------------
60+
61+
@leucos
62+

defaults/main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# -*- yaml -*-
2+
3+
php7_fix_pathinfo: 1
4+
php7_memory_limit: 128M
5+
php7_post_max_size: 40M
6+
php7_upload_max_filesize: 20M

handlers/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- name: Restart php7-fpm
2+
service: name=php7-fpm state=restarted
3+
notify:
4+
- Restart nginx

meta/main.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
galaxy_info:
3+
author: Michel Blanc
4+
description: php7-fpm role
5+
company: ACME Corp
6+
license: MIT
7+
min_ansible_version: 1.8
8+
9+
platforms:
10+
- name: Ubuntu
11+
versions:
12+
- all
13+
- name: Debian
14+
versions:
15+
- all
16+
categories:
17+
- development
18+
19+
dependencies:
20+
- role: ansible-nginx
21+

tasks/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- include: php7-fpm.yml tags=php7-fpm

tasks/php7-fpm.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
- name: Installs php7-fpm
2+
apt: pkg={{ item }} state=latest
3+
notify:
4+
- Restart nginx
5+
with_items:
6+
- php7-fpm
7+
- php-apcu
8+
- php7-mcrypt
9+
- php7-gd
10+
- php7-curl
11+
- php-pear
12+
- php7-mysql
13+
14+
- name: Adds php.ini
15+
template:
16+
src: "../templates/php.ini.j2"
17+
dest: /etc/php/7.0/fpm/php.ini
18+
backup: yes
19+
notify:
20+
- Restart php7-fpm
21+
- Restart nginx
22+
23+
- name: Adds nginx buffer tuning
24+
template:
25+
src: "../templates/fastcgi_buffers.conf.j2"
26+
dest: /etc/nginx/conf.d/fastcgi_buffers.conf
27+
notify:
28+
- Restart php7-fpm
29+
- Restart nginx
30+
31+
- name: Adds pear channels
32+
shell: pear channel-discover {{ item }}
33+
with_items: pear.channels
34+
when: pear is defined
35+
36+
- name: Adds pear packages
37+
shell: pear install {{ item }}
38+
with_items: pear.packages
39+
when: pear is defined
40+

templates/default-fpm.j2

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#
2+
#
3+
server {
4+
listen 80; ## listen for ipv4; this line is default and implied
5+
6+
root {{ nginx_root }};
7+
index index.php index.html index.htm;
8+
9+
# Make site accessible from http://localhost/
10+
server_name _;
11+
12+
location / {
13+
try_files $uri $uri/ /index.php?q=$uri&$args;
14+
# Uncomment to enable naxsi on this location
15+
# include /etc/nginx/naxsi.rules
16+
}
17+
18+
error_page 404 /404.html;
19+
20+
# redirect server error pages to the static page /50x.html
21+
#
22+
error_page 500 502 503 504 /50x.html;
23+
location = /50x.html {
24+
root /usr/share/nginx/html/;
25+
}
26+
27+
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
28+
#
29+
location ~ \.php$ {
30+
try_files $uri =404;
31+
fastcgi_split_path_info ^(.+\.php)(/.+)$;
32+
fastcgi_pass unix:/var/run/php5-fpm.sock;
33+
fastcgi_index index.php;
34+
include fastcgi_params;
35+
}
36+
37+
# deny access to .htaccess files, if Apache's document root
38+
# concurs with nginx's one
39+
#
40+
location ~ /\.ht {
41+
deny all;
42+
}
43+
}

templates/fastcgi_buffers.conf.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fastcgi_buffers 16 32k;
2+
fastcgi_buffer_size 32k;

0 commit comments

Comments
 (0)