Skip to content
This repository was archived by the owner on Oct 7, 2025. It is now read-only.

Commit 5518f67

Browse files
committed
Supporting a fixed PHP version with a fixed port number.
1 parent 51e59f6 commit 5518f67

File tree

6 files changed

+31
-9
lines changed

6 files changed

+31
-9
lines changed

roles/debian/nginx/defaults/main.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ nginx:
2222
# Group prefix. Useful for grouping by environments.
2323
log_group_prefix: ""
2424
# Main log stream for nginx (Cloudwatch).
25-
log_stream_name: example
26-
# We can only have one backend, due to the way we use "common" templates.
27-
# Moving this per domain means instead having templates per project type.
28-
php_fastcgi_backend: "127.0.0.1:90{{ php.version[-1] | replace('.','') }}"
25+
log_stream_name: example # We can only have one backend, due to the way we use "common" templates, moving this per domain means instead having templates per project type.
26+
# See php.fpm.unix_socket, if true use a socket here:
27+
php_fastcgi_backend: "127.0.0.1:90{{ php.version[-1] | replace('.','') }}" # for unix socket use "unix:/var/run/php{{ php.version[-1] | replace('.','') }}-fpm.sock"
2928
ratelimitingcrawlers: false
3029
client_max_body_size: "700M"
3130
fastcgi_read_timeout: 60

roles/debian/nginx/templates/symfony4.j2

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ location ~ \.php(/|$) {
77
fastcgi_pass {{ nginx.php_fastcgi_backend }};
88
fastcgi_split_path_info ^(.+\.php)(/.*)$;
99
include fastcgi_params;
10-
fastcgi_param APP_DEBUG 1;
1110
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
1211
fastcgi_param DOCUMENT_ROOT $realpath_root;
1312
}

roles/debian/php-fpm/defaults/main.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
---
22
php:
3+
# see php-common for default version
34
fpm:
5+
unix_socket: false # set to true to use a unix socket, you must also update nginx and cachetool if you do
6+
tcp_port: "" # leave empty to automate port selection - port will be "90{{ version | replace('.','') }}" - e.g. 9081 for PHP 8.1
47
expose_php: "{% if _env_type == 'prod' %}Off{% else %}On{% endif %}"
58
error_reporting: "{% if _env_type == 'prod' %}E_ALL & ~E_DEPRECATED & ~E_STRICT{% else %}E_ALL{% endif %}"
69
display_errors: "{% if _env_type == 'prod' %}Off{% else %}On{% endif %}"
@@ -21,7 +24,7 @@ php:
2124
max_file_uploads: 20
2225
date_timezone: "Europe/London"
2326
pool_user: "{{ user_deploy.username }}"
24-
pool_group: "{{ user_deploy.username }}"
27+
pool_group: "{{ user_deploy.username }}" # if using unix socket this should be the web server user
2528
default_socket_timeout: 60
2629
max_children: 5
2730
start_servers: 2

roles/debian/php-fpm/tasks/main.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,20 @@
1616
loop_control:
1717
loop_var: version
1818

19-
- name: Copy default pool configuration.
19+
- name: Copy default pool configuration for a single, fixed port PHP version.
20+
ansible.builtin.template:
21+
dest: "/etc/php/{{ php.version[0] }}/fpm/pool.d/www.conf"
22+
src: "www.conf-fixedport.j2"
23+
mode: 0555
24+
when: php.fpm.tcp_port | length > 0
25+
26+
- name: Copy default pool configuration for dynamic PHP versioning.
2027
ansible.builtin.template:
2128
dest: "/etc/php/{{ version }}/fpm/pool.d/www.conf"
2229
src: "www.conf.j2"
2330
mode: 0555
2431
with_items: "{{ php.version }}"
32+
when: php.fpm.tcp_port | length == 0
2533
loop_control:
2634
loop_var: version
2735

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[www]
2+
user = {{ php.fpm.pool_user }}
3+
group = {{ php.fpm.pool_group }}
4+
listen = 127.0.0.1:{{ php.fpm.tcp_port }}
5+
listen.owner = {{ php.fpm.pool_user }}
6+
listen.group = {{ php.fpm.pool_group }}
7+
pm = dynamic
8+
pm.max_children = {{ php.fpm.max_children }}
9+
pm.start_servers = {{ php.fpm.start_servers }}
10+
pm.min_spare_servers = {{ php.fpm.min_spare_servers }}
11+
pm.max_spare_servers = {{ php.fpm.max_spare_servers }}
12+
pm.process_idle_timeout = {{ php.fpm.process_idle_timeout }}
13+
pm.max_requests = {{ php.fpm.max_requests }}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[www]
22
user = {{ php.fpm.pool_user }}
33
group = {{ php.fpm.pool_group }}
4-
listen = 127.0.0.1:90{{ version | replace('.','') }}
4+
listen = {% if php.fpm.unix_socket %}'/var/run/php{{ version | replace('.','') }}-fpm.sock'{% else %}127.0.0.1:90{{ version | replace('.','') }}{% endif %}
55
listen.owner = {{ php.fpm.pool_user }}
66
listen.group = {{ php.fpm.pool_group }}
77
pm = dynamic
@@ -10,4 +10,4 @@ pm.start_servers = {{ php.fpm.start_servers }}
1010
pm.min_spare_servers = {{ php.fpm.min_spare_servers }}
1111
pm.max_spare_servers = {{ php.fpm.max_spare_servers }}
1212
pm.process_idle_timeout = {{ php.fpm.process_idle_timeout }}
13-
pm.max_requests = {{ php.fpm.max_requests }}
13+
pm.max_requests = {{ php.fpm.max_requests }}

0 commit comments

Comments
 (0)