From e5f93062caf110b30e909e7329e29b245890817c Mon Sep 17 00:00:00 2001 From: cytopia Date: Sun, 8 Nov 2020 13:47:02 +0100 Subject: [PATCH] Add PHP 8.1 conf directories --- cfg/php-fpm-8.1/.keepme | 0 cfg/php-fpm-8.1/README.md | 54 +++++++++++++ cfg/php-fpm-8.1/devilbox-fpm.conf-default | 80 +++++++++++++++++++ cfg/php-fpm-8.1/devilbox-fpm.conf-pm_dynamic | 46 +++++++++++ cfg/php-fpm-8.1/devilbox-fpm.conf-pm_ondemand | 39 +++++++++ cfg/php-ini-8.1/.keepme | 0 cfg/php-ini-8.1/README.md | 26 ++++++ cfg/php-ini-8.1/devilbox-php.ini-default | 63 +++++++++++++++ cfg/php-ini-8.1/devilbox-php.ini-xdebug | 36 +++++++++ .../01-update-apt-index.sh-example | 6 ++ cfg/php-startup-8.1/README.md | 29 +++++++ 11 files changed, 379 insertions(+) create mode 100644 cfg/php-fpm-8.1/.keepme create mode 100644 cfg/php-fpm-8.1/README.md create mode 100644 cfg/php-fpm-8.1/devilbox-fpm.conf-default create mode 100644 cfg/php-fpm-8.1/devilbox-fpm.conf-pm_dynamic create mode 100644 cfg/php-fpm-8.1/devilbox-fpm.conf-pm_ondemand create mode 100644 cfg/php-ini-8.1/.keepme create mode 100644 cfg/php-ini-8.1/README.md create mode 100644 cfg/php-ini-8.1/devilbox-php.ini-default create mode 100644 cfg/php-ini-8.1/devilbox-php.ini-xdebug create mode 100755 cfg/php-startup-8.1/01-update-apt-index.sh-example create mode 100644 cfg/php-startup-8.1/README.md diff --git a/cfg/php-fpm-8.1/.keepme b/cfg/php-fpm-8.1/.keepme new file mode 100644 index 00000000..e69de29b diff --git a/cfg/php-fpm-8.1/README.md b/cfg/php-fpm-8.1/README.md new file mode 100644 index 00000000..db30d63f --- /dev/null +++ b/cfg/php-fpm-8.1/README.md @@ -0,0 +1,54 @@ +# PHP-FPM config directory + +## General + +* Add you custom php-fpm.conf files into this directory. +* Only files ending by `.conf` will be enabled +* Only files ending by `.conf` are ignored by git + + +## Example files + +This directory also holds three example files: + +| File | Description | +|---------------------------------|---------------------------------------------| +| `devilbox-fpm.conf-default` | Represents current PHP-FPM default settings | +| `devilbox-fpm.conf-pm_dynamic` | Example settings for dynamic workers | +| `devilbox-fpm.conf-pm_ondemand` | Example settings for ondemand workers | + +* Do not edit these example files! +* Copy them to a new file (in case you want to use them) + + +## Worker configuration + +When changing worker processes or scheduler, the following commands will come in handy +to monitor number of processes and memory consumption. + +```bash +# Show current PHP-FPM child memory consumption in MB +ps -ylC php-fpm --sort:rss | awk '!/RSS/ { s+=$8 } END { printf "%dM\n", s/1024 }' + +# (repeatedly) show current PHP-FPM child memory consumption in MB +watch --interval=1 "ps -ylC php-fpm --sort:rss | awk '"'!'"/RSS/ { s+=\$8 } END { printf \"%dM\n\", s/1024 }'" + +# (repeatedly) Current number of PHP-FPM childs +watch --interval=1 "ps auxw | grep -E 'php-(cgi|fpm)' | grep -vE 'grep|master' | wc -l" +``` + + +## Overwriting + +If multiple `.conf` files are present in this directory specifying different values for the +same settings, the last file (alphabetically by filename) will overwrite any previous values. + + +## Compatibility + +**Note:** + +PHP-FPM 5.2 uses XML-style configuration and does not allow includes. +If you want to change php-fpm.conf for PHP-FPM 5.2 you need to adjust the main configuration file. + +See `php-fpm-5.2/` directory. diff --git a/cfg/php-fpm-8.1/devilbox-fpm.conf-default b/cfg/php-fpm-8.1/devilbox-fpm.conf-default new file mode 100644 index 00000000..37e1f8ed --- /dev/null +++ b/cfg/php-fpm-8.1/devilbox-fpm.conf-default @@ -0,0 +1,80 @@ +; ############################################################ +; Devilbox php-fpm.conf: Current default settings +; ############################################################ +; +; Information +; ----------- +; * Do not edit this file (it belongs to git) +; * This file shows example settings that are currently effective +; * If this file is enabled, nothing will change as it reflects the current default settings +; +; How to enable? +; -------------- +; * Copy this file to another file with ".conf" extension +; * Only files with ".conf" extensions will be applied by PHP-FPM + + +; ### +; ### PHP-FPM global settings +; ### +; +[global] + +; Error log level. Possible values: alert, error, warning, notice, debug. Default value: notice. +log_level = notice + + + +; ### +; ### Pool configuratoin +; ### + +[www] + +; The timeout for serving a single request after which the worker process will be killed. +; This option should be used when the 'max_execution_time' ini option does not stop script +; execution for some reason. +request_terminate_timeout = 120s + + +; A maximum of backlog incoming connections will be queued for processing. +; If a connection request arrives with the queue full the client may receive an error with an +; indication of ECONNREFUSED, or, if the underlying protocol supports retransmission, +; the request may be ignored so that retries may succeed. +; This should not be greater than `cat /proc/sys/net/core/somaxconn`, otherwise connections +; are silently truncated +listen.backlog = 1024 + + +; static - the number of child processes is fixed (pm.max_children). +; +; dynamic - the number of child processes is set dynamically based on the following directives: +; pm.max_children, pm.start_servers, pm.min_spare_servers, pm.max_spare_servers. +; +; ondemand - the processes spawn on demand (when requested, as opposed to dynamic, where +; pm.start_servers are started when the service is started. +pm = ondemand + +; The maximum number of child processes to be created +pm.max_children = 50 + +; The number of child processes created on startup. Used only when pm is set to dynamic. +; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2. +pm.start_servers = 4 + +; The desired minimum number of idle server processes. +pm.min_spare_servers = 2 + +; The desired maximum number of idle server processes. +pm.max_spare_servers = 6 + +; The number of requests each child process should execute before respawning. +; This can be useful to work around memory leaks in 3rd party libraries. +; For endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. +; Default value: 0. +pm.max_requests = 500 + +; The number of seconds after which an idle process will be killed. Used only when pm is set to ondemand +pm.process_idle_timeout = 10s + +; vim: set ft=dosini: diff --git a/cfg/php-fpm-8.1/devilbox-fpm.conf-pm_dynamic b/cfg/php-fpm-8.1/devilbox-fpm.conf-pm_dynamic new file mode 100644 index 00000000..59ec044b --- /dev/null +++ b/cfg/php-fpm-8.1/devilbox-fpm.conf-pm_dynamic @@ -0,0 +1,46 @@ +; ############################################################ +; # Devilbox php-fpm.conf: dynamic example +; ############################################################ +; +; Information +; ----------- +; * Do not edit this file (it belongs to git) +; * This file show a possible dynamic example configuration +; * If this file is enabled, it will overwrite the current worker settings +; +; How to enable? +; -------------- +; * Copy this file to another file with ".conf" extension +; * Only files with ".conf" extensions will be applied by PHP-FPM + + +; ### +; ### Pool configuratoin +; ### + +[www] + +; dynamic - the number of child processes is set dynamically based on the following directives: +pm = dynamic + +; The maximum number of child processes to be created +pm.max_children = 50 + +; The number of child processes created on startup. Used only when pm is set to dynamic. +; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2. +pm.start_servers = 4 + +; The desired minimum number of idle server processes. +pm.min_spare_servers = 2 + +; The desired maximum number of idle server processes. +pm.max_spare_servers = 6 + +; The number of requests each child process should execute before respawning. +; This can be useful to work around memory leaks in 3rd party libraries. +; For endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. +; Default value: 0. +pm.max_requests = 500 + + +; vim: set ft=dosini: diff --git a/cfg/php-fpm-8.1/devilbox-fpm.conf-pm_ondemand b/cfg/php-fpm-8.1/devilbox-fpm.conf-pm_ondemand new file mode 100644 index 00000000..84cd3ca7 --- /dev/null +++ b/cfg/php-fpm-8.1/devilbox-fpm.conf-pm_ondemand @@ -0,0 +1,39 @@ +; ############################################################ +; # Devilbox php-fpm.conf: ondemand example +; ############################################################ +; +; Information +; ----------- +; * Do not edit this file (it belongs to git) +; * This file show a possible ondemand example configuration +; * If this file is enabled, it will overwrite the current worker settings +; +; How to enable? +; -------------- +; * Copy this file to another file with ".conf" extension +; * Only files with ".conf" extensions will be applied by PHP-FPM + + +; ### +; ### Pool configuratoin +; ### + +[www] + +; ondemand - the processes spawn on demand (when requested, as opposed to dynamic, where +; pm.start_servers are started when the service is started. +pm = ondemand + +; The maximum number of child processes to be created +pm.max_children = 50 + +; The number of requests each child process should execute before respawning. +; This can be useful to work around memory leaks in 3rd party libraries. +; For endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. +; Default value: 0. +pm.max_requests = 500 + +; The number of seconds after which an idle process will be killed. +pm.process_idle_timeout = 10s + +; vim: set ft=dosini: diff --git a/cfg/php-ini-8.1/.keepme b/cfg/php-ini-8.1/.keepme new file mode 100644 index 00000000..e69de29b diff --git a/cfg/php-ini-8.1/README.md b/cfg/php-ini-8.1/README.md new file mode 100644 index 00000000..b967fcaa --- /dev/null +++ b/cfg/php-ini-8.1/README.md @@ -0,0 +1,26 @@ +# PHP ini directory + +## General + +* Add you custom php.ini files into this directory. +* Only files ending by `.ini` will be enabled +* Only files ending by `.ini` are ignored by git + + +## Example files + +This directory also holds two example files: + +| File | Description | +|----------------------------|-----------------------------------------| +| `devilbox-php.ini-default` | Represents current PHP default settings | +| `devilbox-php.ini-xdebug ` | Example settings for Xdebug | + +* Do not edit these example files! +* Copy them to a new file (in case you want to use them) + + +## Overwriting + +If multiple `.ini` files are present in this directory specifying different values for the +same settings, the last file (alphabetically by filename) will overwrite any previous values. diff --git a/cfg/php-ini-8.1/devilbox-php.ini-default b/cfg/php-ini-8.1/devilbox-php.ini-default new file mode 100644 index 00000000..83d03712 --- /dev/null +++ b/cfg/php-ini-8.1/devilbox-php.ini-default @@ -0,0 +1,63 @@ +; ############################################################ +; # Devilbox php.ini: Current default settings +; ############################################################ +; +; Information +; ----------- +; * Do not edit this file (it belongs to git) +; * This file shows example settings that are currently effective +; * If this file is enabled, nothing will change as it reflects the current default settings +; +; How to enable? +; -------------- +; * Copy this file to another file with ".ini" extension +; * Only files with ".ini" extensions will be applied by PHP + + + +; +; PHP.ini configuration +; +[PHP] + +; Memory +; Note: "memory_limit" should be larger than "post_max_size" +memory_limit = 512M + + +; Timeouts +max_execution_time = 120 +max_input_time = 120 + + +; Uploads +; Note: "post_max_size" should be greater than "upload_max_filesize" +post_max_size = 72M +upload_max_filesize = 64M +max_file_uploads = 20 + + +; Vars +variables_order = EGPCS +max_input_vars = 8000 +max_input_nesting_level = 64 + + +; Error reporting +; Note: error_log is dynamic and handled during start to set appropriate setting +error_reporting = E_ALL | E_NOTICE | E_STRICT | E_DEPRECATED +xmlrpc_errors = Off +report_memleaks = On +display_errors = On +display_startup_errors = On +log_errors = On +html_errors = On + + +; Xdebug settings +xdebug.default_enable = Off +xdebug.profiler_enable = Off +xdebug.remote_enable = Off +xdebug.remote_autostart = Off + +; vim: set ft=dosini: diff --git a/cfg/php-ini-8.1/devilbox-php.ini-xdebug b/cfg/php-ini-8.1/devilbox-php.ini-xdebug new file mode 100644 index 00000000..d3e977b5 --- /dev/null +++ b/cfg/php-ini-8.1/devilbox-php.ini-xdebug @@ -0,0 +1,36 @@ +; ############################################################ +; # Devilbox php.ini: Xdebug example +; ############################################################ +; +; Information +; ----------- +; * Do not edit this file (it belongs to git) +; * This file show a possible Xdebug example configuration +; * If this file is enabled, it will overwrite the current Xdebug settings +; +; How to enable? +; -------------- +; * Copy this file to another file with ".ini" extension +; * Only files with ".ini" extensions will be applied by PHP + + + +; +; PHP.ini configuration +; +[PHP] + +; Xdebug +; Use these settings to enable Xdebug for PHP +; Make sure to read up on Xdebug some settings might significantly slow down requests. +; The following is just an example configuration and should be adjusted +xdebug.default_enable = On +xdebug.profiler_enable = On +xdebug.remote_enable = On +xdebug.remote_autostart = On +xdebug.remote_handler = dbgp +xdebug.remote_port = 9000 +xdebug.idekey = PHPSTORM +xdebug.remote_log = /var/log/php/xdebug.log + +; vim: set ft=dosini: diff --git a/cfg/php-startup-8.1/01-update-apt-index.sh-example b/cfg/php-startup-8.1/01-update-apt-index.sh-example new file mode 100755 index 00000000..d324ef89 --- /dev/null +++ b/cfg/php-startup-8.1/01-update-apt-index.sh-example @@ -0,0 +1,6 @@ +#!/bin/bash +# +# Simple example showing how to update the packet index +# + +DEBIAN_FRONTEND=noninteractive apt-get update -q diff --git a/cfg/php-startup-8.1/README.md b/cfg/php-startup-8.1/README.md new file mode 100644 index 00000000..e212252e --- /dev/null +++ b/cfg/php-startup-8.1/README.md @@ -0,0 +1,29 @@ +# Custom startup scripts (per PHP version) + +Any script inside this directory ending by `.sh` will be executed during the PHP container startup. +This is useful to apply your custom settings such as installing software that usually requires +the user to accept a license or similar. + +A few examples are given that do not end by `.sh` which won't be run. If you want to use the +provided examples, copy them to a file ending by `.sh` + + +## Info + +If you want to autostart NodeJS applications, you can use [pm2](https://github.com/Unitech/pm2). +Ensure you do this as user `devilbox`, as by default everything is run by root. + +```bash +su -c 'cd /shared/httpd/node/node; pm2 start index.js' -l devilbox +``` + + +## Note + +This directory will startup commands only for a specific PHP version. If you want to run commands +for all versions , go to `autostart/` in the root of the Devilbox git directory. + + +## Important + +All provided scripts will be executed with **root** permissions.