From 6b386c372ad5127a88c9ea0e50790b14c99517c0 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 1 Oct 2021 09:11:49 +0200 Subject: [PATCH 01/21] Custom PHP version --- check_process | 21 ++++++++++++--------- manifest.json | 10 ++++++++++ scripts/_common.sh | 2 +- scripts/install | 2 ++ scripts/upgrade | 7 +++++++ 5 files changed, 32 insertions(+), 10 deletions(-) diff --git a/check_process b/check_process index 32305ef..a38bc8f 100644 --- a/check_process +++ b/check_process @@ -1,10 +1,11 @@ ;; Test complet ; Manifest - domain="domain.tld" (DOMAIN) - path="/path" (PATH) + domain="domain.tld" + path="/path" with_sftp=1 password="myreallystrengthpassword" - is_public=1 (PUBLIC|public=1|private=0) + is_public=1 + php_custom="7.3" with_mysql=1 ; Checks pkg_linter=1 @@ -21,11 +22,12 @@ change_url=1 ;; Test without sftp ; Manifest - domain="domain.tld" (DOMAIN) - path="/path" (PATH) + domain="domain.tld" + path="/path" with_sftp=0 password="" - is_public=1 (PUBLIC|public=1|private=0) + is_public=1 + php_custom="7.3" with_mysql=1 ; Checks setup_sub_dir=1 @@ -33,11 +35,12 @@ backup_restore=1 ;; Test without mysql ; Manifest - domain="domain.tld" (DOMAIN) - path="/path" (PATH) + domain="domain.tld" + path="/path" with_sftp=1 password="myreallystrengthpassword" - is_public=1 (PUBLIC|public=1|private=0) + is_public=1 + php_custom="7.3" with_mysql=0 ; Checks setup_sub_dir=1 diff --git a/manifest.json b/manifest.json index eb4576a..b3b4697 100644 --- a/manifest.json +++ b/manifest.json @@ -59,6 +59,16 @@ "type": "boolean", "default": true }, + { + "name": "php_custom", + "type": "string", + "ask": { + "en": "Choose a PHP version you want to use for your app", + "fr": "Choisissez une version PHP que vous souhaitez utiliser pour votre application" + }, + "choices" : ["7.3", "7.4", "8.0"], + "default" : "7.3" + }, { "name": "with_mysql", "type": "boolean", diff --git a/scripts/_common.sh b/scripts/_common.sh index f5c876d..3c8d0ba 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,7 +4,7 @@ # COMMON VARIABLES #================================================= -YNH_PHP_VERSION="7.3" +YNH_PHP_VERSION="$php_custom" #================================================= # EXPERIMENTAL HELPERS diff --git a/scripts/install b/scripts/install index adfaf91..4428f8d 100644 --- a/scripts/install +++ b/scripts/install @@ -25,6 +25,7 @@ path_url=$YNH_APP_ARG_PATH with_sftp=$YNH_APP_ARG_WITH_SFTP password=$YNH_APP_ARG_PASSWORD is_public=$YNH_APP_ARG_IS_PUBLIC +php_custom=$YNH_APP_ARG_PHP_CUSTOM with_mysql=$YNH_APP_ARG_WITH_MYSQL @@ -52,6 +53,7 @@ ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=with_mysql --value=$with_mysql ynh_app_setting_set --app=$app --key=with_sftp --value=$with_sftp ynh_app_setting_set --app=$app --key=final_path --value=$final_path +ynh_app_setting_set --app=$app --key=php_custom --value=$php_custom ynh_app_setting_set --app=$app --key=admin_mail_html --value=1 diff --git a/scripts/upgrade b/scripts/upgrade index edf7c39..8d5a9e6 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -23,6 +23,7 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name) with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql) with_sftp=$(ynh_app_setting_get --app=$app --key=with_sftp) password=$(ynh_app_setting_get --app=$app --key=password) +php_custom=$(ynh_app_setting_get --app=$app --key=php_custom) admin_mail_html=$(ynh_app_setting_get --app=$app --key=admin_mail_html) @@ -83,6 +84,12 @@ if [ -z "$with_sftp" ]; then ynh_app_setting_set --app=$app --key=with_sftp --value=$with_sftp fi +# If with_sftp doesn't exist, create it +if [ -z "$php_custom" ]; then + php_custom="7.3" + ynh_app_setting_set --app=$app --key=php_custom --value=$php_custom +fi + # Cleaning legacy permissions if ynh_legacy_permissions_exists; then ynh_legacy_permissions_delete_all From 9d0a4bbfdc8df92acde7a97a2c9bb00f93bc6fb2 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 1 Oct 2021 20:15:40 +0200 Subject: [PATCH 02/21] Test PHP8.0 --- check_process | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/check_process b/check_process index a38bc8f..4e7e517 100644 --- a/check_process +++ b/check_process @@ -46,6 +46,19 @@ setup_sub_dir=1 upgrade=1 backup_restore=1 +;; Test with PHP8.0 + ; Manifest + domain="domain.tld" + path="/path" + with_sftp=0 + password="myreallystrengthpassword" + is_public=1 + php_custom="8.0" + with_mysql=0 + ; Checks + setup_sub_dir=1 + upgrade=1 + backup_restore=1 ;;; Options Email= Notification=change From 15b54ab0fad6d9302fcb1722d81d77f3932d40f9 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 1 Oct 2021 20:53:17 +0200 Subject: [PATCH 03/21] Cleaning up --- manifest.json | 6 ++---- scripts/restore | 2 -- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/manifest.json b/manifest.json index b3b4697..6bb9539 100644 --- a/manifest.json +++ b/manifest.json @@ -30,8 +30,7 @@ "install" : [ { "name": "domain", - "type": "domain", - "example": "domain.org" + "type": "domain" }, { "name": "path", @@ -51,8 +50,7 @@ { "name": "password", "type": "password", - "optional": true, - "example": "myreallystrengthpassword" + "optional": true }, { "name": "is_public", diff --git a/scripts/restore b/scripts/restore index 49f60fc..e903d5d 100644 --- a/scripts/restore +++ b/scripts/restore @@ -37,8 +37,6 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= ynh_script_progression --message="Validating restoration parameters..." --weight=2 -ynh_webpath_available --domain=$domain --path_url=$path_url \ - || ynh_die --message="Path not available: ${domain}${path_url}" test ! -d $final_path \ || ynh_die --message="There is already a directory: $final_path " From d2fdec79b597020763bcabe7ca8d7cf21873e2a5 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 1 Oct 2021 21:34:27 +0200 Subject: [PATCH 04/21] Add php-fpm.conf --- conf/extra_php-fpm.conf | 5 - conf/php-fpm.conf | 435 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 435 insertions(+), 5 deletions(-) delete mode 100644 conf/extra_php-fpm.conf create mode 100644 conf/php-fpm.conf diff --git a/conf/extra_php-fpm.conf b/conf/extra_php-fpm.conf deleted file mode 100644 index 2afec46..0000000 --- a/conf/extra_php-fpm.conf +++ /dev/null @@ -1,5 +0,0 @@ -; Additional php.ini defines, specific to this pool of workers. -php_value[upload_max_filesize] = 1G -php_value[post_max_size] = 1G -php_value[default_charset] = UTF-8 -php_value[always_populate_raw_post_data] = -1 diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf new file mode 100644 index 0000000..b7b62c5 --- /dev/null +++ b/conf/php-fpm.conf @@ -0,0 +1,435 @@ +; Start a new pool named 'www'. +; the variable $pool can be used in any directive and will be replaced by the +; pool name ('www' here) +[__NAMETOCHANGE__] + +; Per pool prefix +; It only applies on the following directives: +; - 'access.log' +; - 'slowlog' +; - 'listen' (unixsocket) +; - 'chroot' +; - 'chdir' +; - 'php_values' +; - 'php_admin_values' +; When not set, the global prefix (or /usr) applies instead. +; Note: This directive can also be relative to the global prefix. +; Default Value: none +;prefix = /path/to/pools/$pool + +; Unix user/group of processes +; Note: The user is mandatory. If the group is not set, the default user's group +; will be used. +user = __USER__ +group = __USER__ + +; The address on which to accept FastCGI requests. +; Valid syntaxes are: +; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on +; a specific port; +; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on +; a specific port; +; 'port' - to listen on a TCP socket to all addresses +; (IPv6 and IPv4-mapped) on a specific port; +; '/path/to/unix/socket' - to listen on a unix socket. +; Note: This value is mandatory. +listen = /var/run/php/php__PHPVERSION__-fpm-__NAMETOCHANGE__.sock + +; Set listen(2) backlog. +; Default Value: 511 (-1 on FreeBSD and OpenBSD) +;listen.backlog = 511 + +; Set permissions for unix socket, if one is used. In Linux, read/write +; permissions must be set in order to allow connections from a web server. Many +; BSD-derived systems allow connections regardless of permissions. +; Default Values: user and group are set as the running user +; mode is set to 0660 +listen.owner = www-data +listen.group = www-data +;listen.mode = 0660 +; When POSIX Access Control Lists are supported you can set them using +; these options, value is a comma separated list of user/group names. +; When set, listen.owner and listen.group are ignored +;listen.acl_users = +;listen.acl_groups = + +; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect. +; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original +; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address +; must be separated by a comma. If this value is left blank, connections will be +; accepted from any ip address. +; Default Value: any +;listen.allowed_clients = 127.0.0.1 + +; Specify the nice(2) priority to apply to the pool processes (only if set) +; The value can vary from -19 (highest priority) to 20 (lower priority) +; Note: - It will only work if the FPM master process is launched as root +; - The pool processes will inherit the master process priority +; unless it specified otherwise +; Default Value: no set +; process.priority = -19 + +; Set the process dumpable flag (PR_SET_DUMPABLE prctl) even if the process user +; or group is differrent than the master process user. It allows to create process +; core dump and ptrace the process for the pool user. +; Default Value: no +; process.dumpable = yes + +; Choose how the process manager will control the number of child processes. +; Possible Values: +; static - a fixed number (pm.max_children) of child processes; +; dynamic - the number of child processes are set dynamically based on the +; following directives. With this process management, there will be +; always at least 1 children. +; pm.max_children - the maximum number of children that can +; be alive at the same time. +; pm.start_servers - the number of children created on startup. +; pm.min_spare_servers - the minimum number of children in 'idle' +; state (waiting to process). If the number +; of 'idle' processes is less than this +; number then some children will be created. +; pm.max_spare_servers - the maximum number of children in 'idle' +; state (waiting to process). If the number +; of 'idle' processes is greater than this +; number then some children will be killed. +; ondemand - no children are created at startup. Children will be forked when +; new requests will connect. The following parameter are used: +; pm.max_children - the maximum number of children that +; can be alive at the same time. +; pm.process_idle_timeout - The number of seconds after which +; an idle process will be killed. +; Note: This value is mandatory. +pm = dynamic + +; The number of child processes to be created when pm is set to 'static' and the +; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'. +; This value sets the limit on the number of simultaneous requests that will be +; served. Equivalent to the ApacheMaxClients directive with mpm_prefork. +; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP +; CGI. The below defaults are based on a server without much resources. Don't +; forget to tweak pm.* to fit your needs. +; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand' +; Note: This value is mandatory. +pm.max_children = 5 + +; The number of child processes created on startup. +; Note: Used only when pm is set to 'dynamic' +; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2 +pm.start_servers = 2 + +; The desired minimum number of idle server processes. +; Note: Used only when pm is set to 'dynamic' +; Note: Mandatory when pm is set to 'dynamic' +pm.min_spare_servers = 1 + +; The desired maximum number of idle server processes. +; Note: Used only when pm is set to 'dynamic' +; Note: Mandatory when pm is set to 'dynamic' +pm.max_spare_servers = 3 + +; The number of seconds after which an idle process will be killed. +; Note: Used only when pm is set to 'ondemand' +; Default Value: 10s +;pm.process_idle_timeout = 10s; + +; 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 URI to view the FPM status page. If this value is not set, no URI will be +; recognized as a status page. It shows the following informations: +; pool - the name of the pool; +; process manager - static, dynamic or ondemand; +; start time - the date and time FPM has started; +; start since - number of seconds since FPM has started; +; accepted conn - the number of request accepted by the pool; +; listen queue - the number of request in the queue of pending +; connections (see backlog in listen(2)); +; max listen queue - the maximum number of requests in the queue +; of pending connections since FPM has started; +; listen queue len - the size of the socket queue of pending connections; +; idle processes - the number of idle processes; +; active processes - the number of active processes; +; total processes - the number of idle + active processes; +; max active processes - the maximum number of active processes since FPM +; has started; +; max children reached - number of times, the process limit has been reached, +; when pm tries to start more children (works only for +; pm 'dynamic' and 'ondemand'); +; Value are updated in real time. +; Example output: +; pool: www +; process manager: static +; start time: 01/Jul/2011:17:53:49 +0200 +; start since: 62636 +; accepted conn: 190460 +; listen queue: 0 +; max listen queue: 1 +; listen queue len: 42 +; idle processes: 4 +; active processes: 11 +; total processes: 15 +; max active processes: 12 +; max children reached: 0 +; +; By default the status page output is formatted as text/plain. Passing either +; 'html', 'xml' or 'json' in the query string will return the corresponding +; output syntax. Example: +; http://www.foo.bar/status +; http://www.foo.bar/status?json +; http://www.foo.bar/status?html +; http://www.foo.bar/status?xml +; +; By default the status page only outputs short status. Passing 'full' in the +; query string will also return status for each pool process. +; Example: +; http://www.foo.bar/status?full +; http://www.foo.bar/status?json&full +; http://www.foo.bar/status?html&full +; http://www.foo.bar/status?xml&full +; The Full status returns for each process: +; pid - the PID of the process; +; state - the state of the process (Idle, Running, ...); +; start time - the date and time the process has started; +; start since - the number of seconds since the process has started; +; requests - the number of requests the process has served; +; request duration - the duration in µs of the requests; +; request method - the request method (GET, POST, ...); +; request URI - the request URI with the query string; +; content length - the content length of the request (only with POST); +; user - the user (PHP_AUTH_USER) (or '-' if not set); +; script - the main script called (or '-' if not set); +; last request cpu - the %cpu the last request consumed +; it's always 0 if the process is not in Idle state +; because CPU calculation is done when the request +; processing has terminated; +; last request memory - the max amount of memory the last request consumed +; it's always 0 if the process is not in Idle state +; because memory calculation is done when the request +; processing has terminated; +; If the process is in Idle state, then informations are related to the +; last request the process has served. Otherwise informations are related to +; the current request being served. +; Example output: +; ************************ +; pid: 31330 +; state: Running +; start time: 01/Jul/2011:17:53:49 +0200 +; start since: 63087 +; requests: 12808 +; request duration: 1250261 +; request method: GET +; request URI: /test_mem.php?N=10000 +; content length: 0 +; user: - +; script: /home/fat/web/docs/php/test_mem.php +; last request cpu: 0.00 +; last request memory: 0 +; +; Note: There is a real-time FPM status monitoring sample web page available +; It's available in: /usr/share/php/7.0/fpm/status.html +; +; Note: The value must start with a leading slash (/). The value can be +; 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 + +; 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 +; that FPM is alive and responding, or to +; - create a graph of FPM availability (rrd or such); +; - remove a server from a group if it is not responding (load balancing); +; - trigger alerts for the operating team (24/7). +; Note: The value must start with a leading slash (/). The value can be +; 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 +;ping.path = /ping + +; 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 +;ping.response = pong + +; The access log file +; Default: not set +;access.log = log/$pool.access.log + +; The access log format. +; The following syntax is allowed +; %%: the '%' character +; %C: %CPU used by the request +; it can accept the following format: +; - %{user}C for user CPU only +; - %{system}C for system CPU only +; - %{total}C for user + system CPU (default) +; %d: time taken to serve the request +; it can accept the following format: +; - %{seconds}d (default) +; - %{miliseconds}d +; - %{mili}d +; - %{microseconds}d +; - %{micro}d +; %e: an environment variable (same as $_ENV or $_SERVER) +; it must be associated with embraces to specify the name of the env +; variable. Some exemples: +; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e +; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e +; %f: script filename +; %l: content-length of the request (for POST request only) +; %m: request method +; %M: peak of memory allocated by PHP +; it can accept the following format: +; - %{bytes}M (default) +; - %{kilobytes}M +; - %{kilo}M +; - %{megabytes}M +; - %{mega}M +; %n: pool name +; %o: output header +; it must be associated with embraces to specify the name of the header: +; - %{Content-Type}o +; - %{X-Powered-By}o +; - %{Transfert-Encoding}o +; - .... +; %p: PID of the child that serviced the request +; %P: PID of the parent of the child that serviced the request +; %q: the query string +; %Q: the '?' character if query string exists +; %r: the request URI (without the query string, see %q and %Q) +; %R: remote IP address +; %s: status (response code) +; %t: server time the request was received +; it can accept a strftime(3) format: +; %d/%b/%Y:%H:%M:%S %z (default) +; The strftime(3) format must be encapsuled in a %{}t tag +; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t +; %T: time the log has been written (the request has finished) +; it can accept a strftime(3) format: +; %d/%b/%Y:%H:%M:%S %z (default) +; The strftime(3) format must be encapsuled in a %{}t tag +; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t +; %u: remote user +; +; Default: "%R - %u %t \"%m %r\" %s" +;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%" + +; The log file for slow requests +; Default Value: not set +; Note: slowlog is mandatory if request_slowlog_timeout is set +;slowlog = log/$pool.log.slow + +; The timeout for serving a single request after which a PHP backtrace will be +; dumped to the 'slowlog' file. A value of '0s' means 'off'. +; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) +; Default Value: 0 +;request_slowlog_timeout = 0 + +; 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. A value of '0' means 'off'. +; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) +; Default Value: 0 +request_terminate_timeout = 1d + +; Set open file descriptor rlimit. +; Default Value: system defined value +;rlimit_files = 1024 + +; Set max core size rlimit. +; Possible Values: 'unlimited' or an integer greater or equal to 0 +; Default Value: system defined value +;rlimit_core = 0 + +; Chroot to this directory at the start. This value must be defined as an +; absolute path. When this value is not set, chroot is not used. +; Note: you can prefix with '$prefix' to chroot to the pool prefix or one +; of its subdirectories. If the pool prefix is not set, the global prefix +; will be used instead. +; Note: chrooting is a great security feature and should be used whenever +; possible. However, all PHP paths will be relative to the chroot +; (error_log, sessions.save_path, ...). +; Default Value: not set +;chroot = + +; Chdir to this directory at the start. +; Note: relative path can be used. +; Default Value: current directory or / when chroot +chdir = __FINALPATH__ + +; Redirect worker stdout and stderr into main error log. If not set, stdout and +; stderr will be redirected to /dev/null according to FastCGI specs. +; Note: on highloaded environement, this can cause some delay in the page +; process time (several ms). +; Default Value: no +;catch_workers_output = yes + +; Clear environment in FPM workers +; Prevents arbitrary environment variables from reaching FPM worker processes +; by clearing the environment in workers before env vars specified in this +; pool configuration are added. +; Setting to "no" will make all environment variables available to PHP code +; via getenv(), $_ENV and $_SERVER. +; Default Value: yes +;clear_env = no + +; Limits the extensions of the main script FPM will allow to parse. This can +; prevent configuration mistakes on the web server side. You should only limit +; FPM to .php extensions to prevent malicious users to use other extensions to +; execute php code. +; Note: set an empty value to allow all extensions. +; Default Value: .php +;security.limit_extensions = .php .php3 .php4 .php5 .php7 + +; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from +; the current environment. +; Default Value: clean env +;env[HOSTNAME] = $HOSTNAME +;env[PATH] = /usr/local/bin:/usr/bin:/bin +;env[TMP] = /tmp +;env[TMPDIR] = /tmp +;env[TEMP] = /tmp + +; Additional php.ini defines, specific to this pool of workers. These settings +; overwrite the values previously defined in the php.ini. The directives are the +; same as the PHP SAPI: +; php_value/php_flag - you can set classic ini defines which can +; be overwritten from PHP call 'ini_set'. +; php_admin_value/php_admin_flag - these directives won't be overwritten by +; PHP call 'ini_set' +; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no. + +; Defining 'extension' will load the corresponding shared extension from +; extension_dir. Defining 'disable_functions' or 'disable_classes' will not +; overwrite previously defined php.ini values, but will append the new value +; instead. + +; Note: path INI options can be relative and will be expanded with the prefix +; (pool, global or /usr) + +; Default Value: nothing is defined by default except the values in php.ini and +; specified at startup with the -d argument +;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com +;php_flag[display_errors] = off +;php_admin_value[error_log] = /var/log/fpm-php.www.log +;php_admin_flag[log_errors] = on +;php_admin_value[memory_limit] = 32M + +; Common values to change to increase file upload limit +; php_admin_value[upload_max_filesize] = 50M +; php_admin_value[post_max_size] = 50M +; php_admin_flag[mail.add_x_header] = Off + +; Other common parameters +; php_admin_value[max_execution_time] = 600 +; php_admin_value[max_input_time] = 300 +; php_admin_value[memory_limit] = 256M +; php_admin_flag[short_open_tag] = On + +php_value[upload_max_filesize] = 1G +php_value[post_max_size] = 1G +php_value[default_charset] = UTF-8 +php_value[always_populate_raw_post_data] = -1 From 513b3b6e66f783d579a4957e067bceaf8dce1f88 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 1 Oct 2021 21:37:02 +0200 Subject: [PATCH 05/21] Fix --- scripts/install | 2 +- scripts/upgrade | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 4428f8d..200e9bf 100644 --- a/scripts/install +++ b/scripts/install @@ -142,7 +142,7 @@ chmod o-rwx "$final_path" ynh_script_progression --message="Configuring PHP-FPM..." --weight=2 # Create a dedicatedPHP-FPM config -ynh_add_fpm_config --usage=low --footprint=low +ynh_add_fpm_config --usage=low --footprint=low --phpversion=$YNH_PHP_VERSION phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 8d5a9e6..26b62fb 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -160,7 +160,7 @@ usermod -g "$app" "$app" ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2 # Create a dedicated PHP-FPM config -ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint +ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$YNH_PHP_VERSION #================================================= # SPECIFIC UPGRADE From 38712bb71971cabfd3bb5fc97e3f689320ffca04 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 1 Oct 2021 22:05:32 +0200 Subject: [PATCH 06/21] Update install --- scripts/install | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 200e9bf..d8875a6 100644 --- a/scripts/install +++ b/scripts/install @@ -142,8 +142,7 @@ chmod o-rwx "$final_path" ynh_script_progression --message="Configuring PHP-FPM..." --weight=2 # Create a dedicatedPHP-FPM config -ynh_add_fpm_config --usage=low --footprint=low --phpversion=$YNH_PHP_VERSION -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +ynh_add_fpm_config --usage=low --footprint=low --phpversion=$php_custom #================================================= # GENERIC FINALIZATION From c89da774a6da06a4d9afbff327d18764205b1c0a Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 1 Oct 2021 22:13:04 +0200 Subject: [PATCH 07/21] Fix --- scripts/backup | 4 ++-- scripts/restore | 6 +++--- scripts/upgrade | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/backup b/scripts/backup index 75e9f52..7683783 100644 --- a/scripts/backup +++ b/scripts/backup @@ -28,7 +28,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql) with_sftp=$(ynh_app_setting_get --app=$app --key=with_sftp) -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +php_custom=$(ynh_app_setting_get --app=$app --key=php_custom) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -51,7 +51,7 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" # BACKUP THE PHP-FPM CONFIGURATION #================================================= -ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" +ynh_backup --src_path="/etc/php/$php_custom/fpm/pool.d/$app.conf" #================================================= # BACKUP THE MYSQL DATABASE diff --git a/scripts/restore b/scripts/restore index e903d5d..3dfae49 100644 --- a/scripts/restore +++ b/scripts/restore @@ -30,7 +30,7 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name) with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql) with_sftp=$(ynh_app_setting_get --app=$app --key=with_sftp) password=$(ynh_app_setting_get --app=$app --key=password) -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +php_custom=$(ynh_app_setting_get --app=$app --key=php_custom) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -100,7 +100,7 @@ chmod o-rwx "$final_path" # RESTORE THE PHP-FPM CONFIGURATION #================================================= -ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" +ynh_restore_file --origin_path="/etc/php/${php_custom}/fpm/pool.d/$app.conf" #================================================= # SPECIFIC RESTORATION @@ -113,7 +113,7 @@ ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" #================================================= ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." -ynh_systemd_action --service_name=php$phpversion-fpm --action=reload +ynh_systemd_action --service_name=php${php_custom}-fpm --action=reload ynh_systemd_action --service_name=nginx --action=reload #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 26b62fb..82549be 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -160,7 +160,7 @@ usermod -g "$app" "$app" ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2 # Create a dedicated PHP-FPM config -ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$YNH_PHP_VERSION +ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$php_custom #================================================= # SPECIFIC UPGRADE From fe2bfa67a608d81e422adfdcceda6cf9e68522af Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 2 Oct 2021 00:16:04 +0200 Subject: [PATCH 08/21] Fix PHP selection in NGINX conf --- conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 3f4d62f..8c92d22 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -32,7 +32,7 @@ location __PATH__/ { # Execute and serve PHP files location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; - fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; + fastcgi_pass unix:/var/run/php/php__PHP_CUSTOM__-fpm-__NAME__.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param REMOTE_USER $remote_user; From 16616a2f471a612366cebd53236e7b13e82b0017 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 2 Oct 2021 10:12:28 +0200 Subject: [PATCH 09/21] Fix PHP selection in PHP-FPM conf --- conf/php-fpm.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf index b7b62c5..65d7b6a 100644 --- a/conf/php-fpm.conf +++ b/conf/php-fpm.conf @@ -33,7 +33,7 @@ group = __USER__ ; (IPv6 and IPv4-mapped) on a specific port; ; '/path/to/unix/socket' - to listen on a unix socket. ; Note: This value is mandatory. -listen = /var/run/php/php__PHPVERSION__-fpm-__NAMETOCHANGE__.sock +listen = /var/run/php/php__PHP_CUSTOM__-fpm-__NAMETOCHANGE__.sock ; Set listen(2) backlog. ; Default Value: 511 (-1 on FreeBSD and OpenBSD) From 563099da3a24f7e9d1c9ac338e00ea351d630134 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 2 Oct 2021 10:35:13 +0200 Subject: [PATCH 10/21] Use PHPVERSION as PHP selection variable --- conf/nginx.conf | 2 +- conf/php-fpm.conf | 2 +- manifest.json | 2 +- scripts/_common.sh | 2 -- scripts/backup | 4 ++-- scripts/install | 6 +++--- scripts/restore | 6 +++--- scripts/upgrade | 10 ++-------- 8 files changed, 13 insertions(+), 21 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 8c92d22..3f4d62f 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -32,7 +32,7 @@ location __PATH__/ { # Execute and serve PHP files location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; - fastcgi_pass unix:/var/run/php/php__PHP_CUSTOM__-fpm-__NAME__.sock; + fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param REMOTE_USER $remote_user; diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf index 65d7b6a..b7b62c5 100644 --- a/conf/php-fpm.conf +++ b/conf/php-fpm.conf @@ -33,7 +33,7 @@ group = __USER__ ; (IPv6 and IPv4-mapped) on a specific port; ; '/path/to/unix/socket' - to listen on a unix socket. ; Note: This value is mandatory. -listen = /var/run/php/php__PHP_CUSTOM__-fpm-__NAMETOCHANGE__.sock +listen = /var/run/php/php__PHPVERSION__-fpm-__NAMETOCHANGE__.sock ; Set listen(2) backlog. ; Default Value: 511 (-1 on FreeBSD and OpenBSD) diff --git a/manifest.json b/manifest.json index 6bb9539..8c366f8 100644 --- a/manifest.json +++ b/manifest.json @@ -58,7 +58,7 @@ "default": true }, { - "name": "php_custom", + "name": "phpversion", "type": "string", "ask": { "en": "Choose a PHP version you want to use for your app", diff --git a/scripts/_common.sh b/scripts/_common.sh index 3c8d0ba..ed3594e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,8 +4,6 @@ # COMMON VARIABLES #================================================= -YNH_PHP_VERSION="$php_custom" - #================================================= # EXPERIMENTAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index 7683783..02c3e3b 100644 --- a/scripts/backup +++ b/scripts/backup @@ -28,7 +28,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql) with_sftp=$(ynh_app_setting_get --app=$app --key=with_sftp) -php_custom=$(ynh_app_setting_get --app=$app --key=php_custom) +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -51,7 +51,7 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" # BACKUP THE PHP-FPM CONFIGURATION #================================================= -ynh_backup --src_path="/etc/php/$php_custom/fpm/pool.d/$app.conf" +ynh_backup --src_path="/etc/php/${phpversion}/fpm/pool.d/$app.conf" #================================================= # BACKUP THE MYSQL DATABASE diff --git a/scripts/install b/scripts/install index d8875a6..3d8ac96 100644 --- a/scripts/install +++ b/scripts/install @@ -25,7 +25,7 @@ path_url=$YNH_APP_ARG_PATH with_sftp=$YNH_APP_ARG_WITH_SFTP password=$YNH_APP_ARG_PASSWORD is_public=$YNH_APP_ARG_IS_PUBLIC -php_custom=$YNH_APP_ARG_PHP_CUSTOM +phpversion=$YNH_APP_ARG_PHPVERSION with_mysql=$YNH_APP_ARG_WITH_MYSQL @@ -53,7 +53,7 @@ ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=with_mysql --value=$with_mysql ynh_app_setting_set --app=$app --key=with_sftp --value=$with_sftp ynh_app_setting_set --app=$app --key=final_path --value=$final_path -ynh_app_setting_set --app=$app --key=php_custom --value=$php_custom +ynh_app_setting_set --app=$app --key=phpversion --value=$phpversion ynh_app_setting_set --app=$app --key=admin_mail_html --value=1 @@ -142,7 +142,7 @@ chmod o-rwx "$final_path" ynh_script_progression --message="Configuring PHP-FPM..." --weight=2 # Create a dedicatedPHP-FPM config -ynh_add_fpm_config --usage=low --footprint=low --phpversion=$php_custom +ynh_add_fpm_config --usage=low --footprint=low --phpversion=$phpversion #================================================= # GENERIC FINALIZATION diff --git a/scripts/restore b/scripts/restore index 3dfae49..18f23a2 100644 --- a/scripts/restore +++ b/scripts/restore @@ -30,7 +30,7 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name) with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql) with_sftp=$(ynh_app_setting_get --app=$app --key=with_sftp) password=$(ynh_app_setting_get --app=$app --key=password) -php_custom=$(ynh_app_setting_get --app=$app --key=php_custom) +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -100,7 +100,7 @@ chmod o-rwx "$final_path" # RESTORE THE PHP-FPM CONFIGURATION #================================================= -ynh_restore_file --origin_path="/etc/php/${php_custom}/fpm/pool.d/$app.conf" +ynh_restore_file --origin_path="/etc/php/${phpversion}/fpm/pool.d/$app.conf" #================================================= # SPECIFIC RESTORATION @@ -113,7 +113,7 @@ ynh_restore_file --origin_path="/etc/php/${php_custom}/fpm/pool.d/$app.conf" #================================================= ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." -ynh_systemd_action --service_name=php${php_custom}-fpm --action=reload +ynh_systemd_action --service_name=php${phpversion}-fpm --action=reload ynh_systemd_action --service_name=nginx --action=reload #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 82549be..0cbd54c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -23,7 +23,7 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name) with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql) with_sftp=$(ynh_app_setting_get --app=$app --key=with_sftp) password=$(ynh_app_setting_get --app=$app --key=password) -php_custom=$(ynh_app_setting_get --app=$app --key=php_custom) +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) admin_mail_html=$(ynh_app_setting_get --app=$app --key=admin_mail_html) @@ -84,12 +84,6 @@ if [ -z "$with_sftp" ]; then ynh_app_setting_set --app=$app --key=with_sftp --value=$with_sftp fi -# If with_sftp doesn't exist, create it -if [ -z "$php_custom" ]; then - php_custom="7.3" - ynh_app_setting_set --app=$app --key=php_custom --value=$php_custom -fi - # Cleaning legacy permissions if ynh_legacy_permissions_exists; then ynh_legacy_permissions_delete_all @@ -160,7 +154,7 @@ usermod -g "$app" "$app" ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2 # Create a dedicated PHP-FPM config -ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$php_custom +ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$phpversion #================================================= # SPECIFIC UPGRADE From e7c904b2678e15b737b21080725f989a057d8496 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 2 Oct 2021 13:08:35 +0200 Subject: [PATCH 11/21] Update check_process --- check_process | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/check_process b/check_process index 4e7e517..d0e42dd 100644 --- a/check_process +++ b/check_process @@ -5,7 +5,7 @@ with_sftp=1 password="myreallystrengthpassword" is_public=1 - php_custom="7.3" + phpversion="7.3" with_mysql=1 ; Checks pkg_linter=1 @@ -27,7 +27,7 @@ with_sftp=0 password="" is_public=1 - php_custom="7.3" + phpversion="7.3" with_mysql=1 ; Checks setup_sub_dir=1 @@ -40,7 +40,7 @@ with_sftp=1 password="myreallystrengthpassword" is_public=1 - php_custom="7.3" + phpversion="7.3" with_mysql=0 ; Checks setup_sub_dir=1 @@ -53,7 +53,7 @@ with_sftp=0 password="myreallystrengthpassword" is_public=1 - php_custom="8.0" + phpversion="8.0" with_mysql=0 ; Checks setup_sub_dir=1 From 22fd9b40a2500861ae413767c1dca4a89715b356 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Tue, 16 Nov 2021 09:42:26 +0100 Subject: [PATCH 12/21] Update upgrade --- scripts/upgrade | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 0cbd54c..30c3de3 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -36,6 +36,20 @@ fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage) upgrade_type=$(ynh_check_app_version_changed) +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=3 + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -91,20 +105,6 @@ if ynh_legacy_permissions_exists; then ynh_app_setting_delete --app=$app --key=is_public fi -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=3 - -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - #================================================= # ACTIVATE MAINTENANCE MODE #================================================= From a6aedd3c643d61dbd8eabe0d95177a20a7a6f81c Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Tue, 16 Nov 2021 09:44:31 +0100 Subject: [PATCH 13/21] Update check_process --- check_process | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/check_process b/check_process index d0e42dd..a41f35b 100644 --- a/check_process +++ b/check_process @@ -46,6 +46,19 @@ setup_sub_dir=1 upgrade=1 backup_restore=1 +;; Test with PHP7.4 + ; Manifest + domain="domain.tld" + path="/path" + with_sftp=0 + password="myreallystrengthpassword" + is_public=1 + phpversion="7.4" + with_mysql=0 + ; Checks + setup_sub_dir=1 + upgrade=1 + backup_restore=1 ;; Test with PHP8.0 ; Manifest domain="domain.tld" From 5c0f2abaa68056fdf6c9598dea371b8449867178 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Fri, 26 Nov 2021 00:02:25 +0100 Subject: [PATCH 14/21] Install PHP-FPM as dependency --- manifest.json | 2 +- scripts/install | 7 +++++++ scripts/upgrade | 13 +++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 8c366f8..fa26fe2 100644 --- a/manifest.json +++ b/manifest.json @@ -18,7 +18,7 @@ "email": "maniackc_dev@crudelis.fr" }], "requirements": { - "yunohost": ">= 4.2.3" + "yunohost": ">= 4.3.3" }, "multi_instance": true, "services": [ diff --git a/scripts/install b/scripts/install index 3d8ac96..716b9e1 100644 --- a/scripts/install +++ b/scripts/install @@ -59,6 +59,13 @@ ynh_app_setting_set --app=$app --key=admin_mail_html --value=1 #================================================= # STANDARD MODIFICATIONS +#================================================= +# INSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Installing dependencies..." --weight=1 + +ynh_install_app_dependencies "php${phpversion}-fpm" + #================================================= # CREATE A MYSQL DATABASE #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 30c3de3..db5936a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -98,6 +98,12 @@ if [ -z "$with_sftp" ]; then ynh_app_setting_set --app=$app --key=with_sftp --value=$with_sftp fi +# If phpversion doesn't exist, create it +if [ -z "$phpversion" ]; then + phpversion=$YNH_PHP_VERSION + ynh_app_setting_set --app=$app --key=phpversion --value=$phpversion +fi + # Cleaning legacy permissions if ynh_legacy_permissions_exists; then ynh_legacy_permissions_delete_all @@ -114,6 +120,13 @@ ynh_maintenance_mode_ON #================================================= # STANDARD UPGRADE STEPS +#================================================= +# INSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Installing dependencies..." --weight=1 + +ynh_install_app_dependencies "php${phpversion}-fpm" + #================================================= # NGINX CONFIGURATION #================================================= From 158dd75552301915b7f52541c0837a90d382dea8 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Fri, 26 Nov 2021 00:06:50 +0100 Subject: [PATCH 15/21] Add PHP version selection in READMEs --- README.md | 2 ++ README_fr.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/README.md b/README.md index a149a67..87873c9 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ which will be backed up and restored with your application. The connection details will be stored in the file `db_accesss.txt` located in the root directory. +PHP-FPM version can also be selected among 7.3, 7.4, and 8.0. + **Once installed, go to the chosen URL to know the user, domain and port you will have to use for the SFTP access.** The password is one you chosen during the installation. Under the Web directory, you will see a `www` folder diff --git a/README_fr.md b/README_fr.md index d3dba43..6c385c1 100644 --- a/README_fr.md +++ b/README_fr.md @@ -15,6 +15,8 @@ fourni un accès aux fichiers avec [SFTP](https://yunohost.org/fr/filezilla). El qui sera sauvegardée et restaurée avec votre application. Les détails de connexion seront stockés dans le fichier `db_accesss.txt` situé dans le répertoire racine. +La version de PHP-FPM peut aussi être choisie, parmi 7.3, 7.4, et 8.0. + **Version incluse :** 1.0 ## Configuration From 5157c96777cadc57f6915eeace5e4e14d504545d Mon Sep 17 00:00:00 2001 From: tituspijean Date: Fri, 26 Nov 2021 12:57:16 +0100 Subject: [PATCH 16/21] Add PHP dependency in restore script --- scripts/restore | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/restore b/scripts/restore index 18f23a2..0062b46 100644 --- a/scripts/restore +++ b/scripts/restore @@ -42,6 +42,13 @@ test ! -d $final_path \ #================================================= # STANDARD RESTORATION STEPS +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Reinstalling dependencies..." --weight=2 + +ynh_install_app_dependencies "php${phpversion}-fpm" + #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= From 6e424af31d3a8b3e1210480d1c5fd1664390d901 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Fri, 26 Nov 2021 12:58:37 +0100 Subject: [PATCH 17/21] Homogeinize dependencies install step weight --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 716b9e1..4007581 100644 --- a/scripts/install +++ b/scripts/install @@ -62,7 +62,7 @@ ynh_app_setting_set --app=$app --key=admin_mail_html --value=1 #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --weight=1 +ynh_script_progression --message="Installing dependencies..." --weight=2 ynh_install_app_dependencies "php${phpversion}-fpm" From a1161adabdd8b62021b5e791c196daa1821b9b3c Mon Sep 17 00:00:00 2001 From: tituspijean Date: Fri, 26 Nov 2021 12:58:58 +0100 Subject: [PATCH 18/21] =?UTF-8?q?Homogeinize=20dependencies=20install=20st?= =?UTF-8?q?ep=20weight=C2=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index db5936a..61f2316 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -123,7 +123,7 @@ ynh_maintenance_mode_ON #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --weight=1 +ynh_script_progression --message="Installing dependencies..." --weight=2 ynh_install_app_dependencies "php${phpversion}-fpm" From e30b16245f3c9caac627a9873edb74f19bed80ac Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sun, 26 Dec 2021 11:58:22 +0100 Subject: [PATCH 19/21] Stop PHP-FPM service before attempting to delete old system user --- scripts/upgrade | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index 61f2316..1dd760d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -58,8 +58,10 @@ ynh_script_progression --message="Ensuring downward compatibility..." # Delete old user if [ -n "$(ynh_app_setting_get --app=$app --key=user)" ] then + ynh_systemd_action --service_name=php${phpversion}-fpm --action=stop ynh_system_user_delete --username="$(ynh_app_setting_get --app=$app --key=user)" ynh_app_setting_delete --app=$app --key=user + ynh_systemd_action --service_name=php${phpversion}-fpm --action=start fi # If db_name doesn't exist, create it From 6c9c7d3a0908d15d4946a547c725497ce830180f Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sun, 26 Dec 2021 13:41:02 +0100 Subject: [PATCH 20/21] Remove PHP-FPM config before attempting to delete old system user --- scripts/upgrade | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 1dd760d..82bd939 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -55,15 +55,6 @@ ynh_abort_if_errors #================================================= ynh_script_progression --message="Ensuring downward compatibility..." -# Delete old user -if [ -n "$(ynh_app_setting_get --app=$app --key=user)" ] -then - ynh_systemd_action --service_name=php${phpversion}-fpm --action=stop - ynh_system_user_delete --username="$(ynh_app_setting_get --app=$app --key=user)" - ynh_app_setting_delete --app=$app --key=user - ynh_systemd_action --service_name=php${phpversion}-fpm --action=start -fi - # If db_name doesn't exist, create it if [ -z "$db_name" ]; then db_name=$(ynh_sanitize_dbid --db_name=$app) @@ -106,6 +97,14 @@ if [ -z "$phpversion" ]; then ynh_app_setting_set --app=$app --key=phpversion --value=$phpversion fi +# Delete old user +if [ -n "$(ynh_app_setting_get --app=$app --key=user)" ] +then + ynh_systemd_action --service_name=php${phpversion}-fpm --action=stop + ynh_system_user_delete --username="$(ynh_app_setting_get --app=$app --key=user)" + ynh_app_setting_delete --app=$app --key=user +fi + # Cleaning legacy permissions if ynh_legacy_permissions_exists; then ynh_legacy_permissions_delete_all From 51821b21e8bcef9fea9c117528cb7836c3829110 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sun, 9 Jan 2022 11:54:01 +0100 Subject: [PATCH 21/21] Add option to not install PHP --- check_process | 13 +++++++++ conf/nginx_no_php.conf | 34 ++++++++++++++++++++++++ conf/{nginx.conf => nginx_with_php.conf} | 0 manifest.json | 2 +- scripts/change_url | 9 +++++++ scripts/install | 26 ++++++++++++++---- scripts/upgrade | 25 +++++++++++++---- 7 files changed, 98 insertions(+), 11 deletions(-) create mode 100644 conf/nginx_no_php.conf rename conf/{nginx.conf => nginx_with_php.conf} (100%) diff --git a/check_process b/check_process index a41f35b..c2fc7c2 100644 --- a/check_process +++ b/check_process @@ -46,6 +46,19 @@ setup_sub_dir=1 upgrade=1 backup_restore=1 +;; Test without PHP + ; Manifest + domain="domain.tld" + path="/path" + with_sftp=0 + password="myreallystrengthpassword" + is_public=1 + phpversion="none" + with_mysql=0 + ; Checks + setup_sub_dir=1 + upgrade=1 + backup_restore=1 ;; Test with PHP7.4 ; Manifest domain="domain.tld" diff --git a/conf/nginx_no_php.conf b/conf/nginx_no_php.conf new file mode 100644 index 0000000..5367ecf --- /dev/null +++ b/conf/nginx_no_php.conf @@ -0,0 +1,34 @@ +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; +location __PATH__/ { + + # Path to source + alias __FINALPATH__/www/; + + # Force usage of https + if ($scheme = http) { + rewrite ^ https://$server_name$request_uri? permanent; + } + + # Default indexes and catch-all + index index.html index.php; + try_files $uri $uri/ __PATH__/index.php?$args; + + # Prevent useless logs + location = __PATH__/favicon.ico { + log_not_found off; + access_log off; + } + location = __PATH__/robots.txt { + allow all; + log_not_found off; + access_log off; + } + + # Deny access to hidden files and directories + location ~ ^__PATH__/(.+/|)\.(?!well-known\/) { + deny all; + } + + # Include SSOWAT user panel. + include conf.d/yunohost_panel.conf.inc; +} diff --git a/conf/nginx.conf b/conf/nginx_with_php.conf similarity index 100% rename from conf/nginx.conf rename to conf/nginx_with_php.conf diff --git a/manifest.json b/manifest.json index fa26fe2..705847a 100644 --- a/manifest.json +++ b/manifest.json @@ -64,7 +64,7 @@ "en": "Choose a PHP version you want to use for your app", "fr": "Choisissez une version PHP que vous souhaitez utiliser pour votre application" }, - "choices" : ["7.3", "7.4", "8.0"], + "choices" : ["none", "7.3", "7.4", "8.0"], "default" : "7.3" }, { diff --git a/scripts/change_url b/scripts/change_url index 6a9ca89..39f7c11 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -28,6 +28,7 @@ ynh_script_progression --message="Loading installation settings..." # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP @@ -80,6 +81,14 @@ ynh_script_progression --message="Updating NGINX web server configuration..." -- nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf +# Prepare nginx.conf +if [ $phpversion != "none" ] +then + cp ../conf/nginx{_with_php,}.conf +else + cp ../conf/nginx{_no_php,}.conf +fi + # Change the path in the NGINX config file if [ $change_path -eq 1 ] then diff --git a/scripts/install b/scripts/install index 4007581..1cddee6 100644 --- a/scripts/install +++ b/scripts/install @@ -62,9 +62,13 @@ ynh_app_setting_set --app=$app --key=admin_mail_html --value=1 #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --weight=2 -ynh_install_app_dependencies "php${phpversion}-fpm" +if [ $phpversion != "none" ] +then + ynh_script_progression --message="Installing dependencies..." --weight=2 + + ynh_install_app_dependencies "php${phpversion}-fpm" +fi #================================================= # CREATE A MYSQL DATABASE @@ -84,6 +88,14 @@ fi #================================================= ynh_script_progression --message="Configuring NGINX web server..." --weight=2 +# Prepare nginx.conf +if [ $phpversion != "none" ] +then + cp ../conf/nginx{_with_php,}.conf +else + cp ../conf/nginx{_no_php,}.conf +fi + # Create a dedicated NGINX config ynh_add_nginx_config @@ -146,10 +158,14 @@ chmod o-rwx "$final_path" #================================================= # PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Configuring PHP-FPM..." --weight=2 -# Create a dedicatedPHP-FPM config -ynh_add_fpm_config --usage=low --footprint=low --phpversion=$phpversion +if [ $phpversion != "none" ] +then + ynh_script_progression --message="Configuring PHP-FPM..." --weight=2 + + # Create a dedicatedPHP-FPM config + ynh_add_fpm_config --usage=low --footprint=low --phpversion=$phpversion +fi #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index 82bd939..5f98d6d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -124,9 +124,13 @@ ynh_maintenance_mode_ON #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --weight=2 -ynh_install_app_dependencies "php${phpversion}-fpm" +if [ $phpversion != "none" ] +then + ynh_script_progression --message="Installing dependencies..." --weight=2 + + ynh_install_app_dependencies "php${phpversion}-fpm" +fi #================================================= # NGINX CONFIGURATION @@ -134,6 +138,14 @@ ynh_install_app_dependencies "php${phpversion}-fpm" ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2 +# Prepare nginx.conf +if [ $phpversion != "none" ] +then + cp ../conf/nginx{_with_php,}.conf +else + cp ../conf/nginx{_no_php,}.conf +fi + # Create a dedicated NGINX config ynh_add_nginx_config @@ -165,10 +177,13 @@ usermod -g "$app" "$app" # PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2 +if [ $phpversion != "none" ] +then + ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2 -# Create a dedicated PHP-FPM config -ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$phpversion + # Create a dedicated PHP-FPM config + ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$phpversion +fi #================================================= # SPECIFIC UPGRADE