From 6ab40e73c4348cd72590b9bb5e1d6347cb35666a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C5=A1a=20Todorovi=C4=87?= Date: Tue, 1 Nov 2022 17:02:14 +0100 Subject: [PATCH 1/2] Fix wrong else statements in stack_services.py --- wo/cli/plugins/stack_services.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wo/cli/plugins/stack_services.py b/wo/cli/plugins/stack_services.py index 7d83a3c..341eb9e 100644 --- a/wo/cli/plugins/stack_services.py +++ b/wo/cli/plugins/stack_services.py @@ -286,15 +286,15 @@ class WOStackStatusController(CementBaseController): if os.path.exists('{0}'.format(wo_system) + 'php7.4-fpm.service'): services = services + ['php7.4-fpm'] else: - Log.info(self, "PHP8.0-FPM is not installed") + Log.info(self, "PHP7.4-FPM is not installed") if os.path.exists('{0}'.format(wo_system) + 'php8.0-fpm.service'): services = services + ['php8.0-fpm'] else: - Log.info(self, "PHP8.1-FPM is not installed") + Log.info(self, "PHP8.0-FPM is not installed") if os.path.exists('{0}'.format(wo_system) + 'php8.1-fpm.service'): services = services + ['php8.1-fpm'] else: - Log.info(self, "PHP7.4-FPM is not installed") + Log.info(self, "PHP8.1-FPM is not installed") if pargs.php72: if os.path.exists('{0}'.format(wo_system) + 'php7.2-fpm.service'): From a76d76ce5f366c238e5dea453c66cffb6b3a69d9 Mon Sep 17 00:00:00 2001 From: Janio Sarmento Date: Sat, 10 Dec 2022 10:37:20 -0300 Subject: [PATCH 2/2] #482: Add PHP 8.2 to WO --- README.md | 10 +- config/bash_completion.d/wo_auto.rc | 30 ++--- tests/travis.sh | 31 ++++- wo/cli/plugins/info.py | 100 +++++++++++++++- wo/cli/plugins/site_functions.py | 74 +++++++++--- wo/cli/plugins/stack.py | 93 ++++++++++++--- wo/cli/plugins/stack_pref.py | 179 +++++++++++++++++++++++++++- wo/cli/plugins/stack_services.py | 64 ++++++++-- wo/cli/plugins/stack_upgrade.py | 14 ++- wo/cli/templates/upstream.mustache | 23 +++- wo/core/services.py | 4 +- wo/core/variables.py | 3 + 12 files changed, 556 insertions(+), 69 deletions(-) diff --git a/README.md b/README.md index a837665..15aa1d6 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ - **Easy to install** : One step automated installer with migration from EasyEngine v3 support - **Fast deployment** : Fast and automated WordPress, Nginx, PHP, MySQL & Redis installation - **Custom Nginx build** : Nginx 1.22.1 - TLS v1.3 Cloudflare HTTP/2 HPACK & Brotli support -- **Up-to-date** : PHP 7.2, 7.3, 7.4, 8.0 & 8.1 - MariaDB 10.6 & Redis 7.0 +- **Up-to-date** : PHP 7.2, 7.3, 7.4, 8.0, 8.1 & 8.2 - MariaDB 10.6 & Redis 7.0 - **Secured** : Hardened WordPress security with strict Nginx location directives - **Powerful** : Optimized Nginx configurations with multiple cache backends support - **SSL** : Domain, Subdomain & Wildcard Let's Encrypt SSL certificates with DNS API support @@ -87,8 +87,8 @@ Detailed Getting Started guide with additional installation methods can be found ### Standard WordPress sites ```bash -wo site create example.com --wp # install wordpress with PHP 8.0 without any page caching -wo site create example.com --wp --php81 # install wordpress with PHP 8.1 without any page caching +wo site create example.com --wp # install wordpress with PHP 8.1 without any page caching +wo site create example.com --wp --php82 # install wordpress with PHP 8.2 without any page caching wo site create example.com --wpfc # install wordpress + nginx fastcgi_cache wo site create example.com --wpredis # install wordpress + nginx redis_cache wo site create example.com --wprocket # install wordpress with WP-Rocket plugin @@ -125,7 +125,8 @@ wo site create example.com --html # create example.com for static/html sites wo site create example.com --php # create example.com with php 8.0 support wo site create example.com --php80 # create example.com with php 8.0 support wo site create example.com --php81 # create example.com with php 8.1 support -wo site create example.com --mysql # create example.com with php 8.0 & mysql support +wo site create example.com --php82 # create example.com with php 8.1 support +wo site create example.com --mysql # create example.com with php 8.1 & mysql support wo site create example.com --mysql --php81 # create example.com with php 8.1 & mysql support wo site create example.com --proxy=127.0.0.1:3000 # create example.com with nginx as reverse-proxy ``` @@ -138,6 +139,7 @@ wo site update example.com --php73 # switch to PHP 7.3 wo site update example.com --php74 # switch to PHP 7.4 wo site update example.com --php80 # switch to PHP 8.0 wo site update example.com --php81 # switch to PHP 8.1 +wo site update example.com --php82 # switch to PHP 8.2 ``` ### Sites secured with Let's Encrypt diff --git a/config/bash_completion.d/wo_auto.rc b/config/bash_completion.d/wo_auto.rc index 4f71ed4..eef9c14 100644 --- a/config/bash_completion.d/wo_auto.rc +++ b/config/bash_completion.d/wo_auto.rc @@ -74,12 +74,12 @@ _wo_complete() # HANDLE EVERYTHING AFTER THE THIRD LEVEL NAMESPACE "install" | "purge" | "remove" ) COMPREPLY=( $(compgen \ - -W "--web --admin --security --nginx --php72 --php73 --php74 --php80 --php81 --mysql --wpcli --phpmyadmin --adminer --utils --redis --phpredisadmin --composer --netdata --fail2ban --ufw --dashboard --proftpd --clamav --sendmail --ngxblocker --mysqlclient --mysqltuner --extplorer --nanorc --cheat --all --force" \ + -W "--web --admin --security --nginx --php72 --php73 --php74 --php80 --php81 --php82 --mysql --wpcli --phpmyadmin --adminer --utils --redis --phpredisadmin --composer --netdata --fail2ban --ufw --dashboard --proftpd --clamav --sendmail --ngxblocker --mysqlclient --mysqltuner --extplorer --nanorc --cheat --all --force" \ -- $cur) ) ;; "upgrade" ) COMPREPLY=( $(compgen \ - -W "--web --admin --utils --nginx --php72 --php73 --php74 --php80 --php81 --mysql --all --netdata --composer --phpmyadmin --adminer --dashboard --mysqltuner --wpcli --force" \ + -W "--web --admin --utils --nginx --php72 --php73 --php74 --php80 --php81 --php82 --mysql --all --netdata --composer --phpmyadmin --adminer --dashboard --mysqltuner --wpcli --force" \ -- $cur) ) ;; "migrate") @@ -89,7 +89,7 @@ _wo_complete() ;; "start" | "stop" | "reload" | "restart" | "status") COMPREPLY=( $(compgen \ - -W "--nginx --php --php72 --php73 --php74 --php80 --php81 --mysql --redis --fail2ban --ufw --netdata -proftpd" \ + -W "--nginx --php --php72 --php73 --php74 --php80 --php81 --php82 --mysql --redis --fail2ban --ufw --netdata -proftpd" \ -- $cur) ) ;; "list") @@ -159,13 +159,13 @@ _wo_complete() "create") COMPREPLY=( $(compgen \ - -W "--user --pass --email --html --php --php72 --php73 --php74 --php80 --php81 --mysql --wp --wpsubdir --wpsubdomain --wpfc --wpsc --proxy= --wpredis --wprocket --wpce -le --letsencrypt --letsencrypt=wildcard -le=wildcard --dns --dns=dns_cf --dns=dns_dgon" \ + -W "--user --pass --email --html --php --php72 --php73 --php74 --php80 --php81 --php82 --mysql --wp --wpsubdir --wpsubdomain --wpfc --wpsc --proxy= --wpredis --wprocket --wpce -le --letsencrypt --letsencrypt=wildcard -le=wildcard --dns --dns=dns_cf --dns=dns_dgon" \ -- $cur) ) ;; "update") COMPREPLY=( $(compgen \ - -W "--password --php --php72 --php73 --php74 --php80 --php81 --mysql --wp --wpsubdir --wpsubdomain --wpfc --wpsc --wpredis --wprocket --wpce -le -le=off --letsencrypt --letsencrypt=off --letsencrypt=clean -le=wildcard -le=clean --dns --dns=dns_cf --dns=dns_dgon --ngxblocker --ngxblocker=off" \ + -W "--password --php --php72 --php73 --php74 --php80 --php81 --php82 --mysql --wp --wpsubdir --wpsubdomain --wpfc --wpsc --wpredis --wprocket --wpce -le -le=off --letsencrypt --letsencrypt=off --letsencrypt=clean -le=wildcard -le=clean --dns --dns=dns_cf --dns=dns_dgon --ngxblocker --ngxblocker=off" \ -- $cur) ) ;; "delete") @@ -211,9 +211,9 @@ _wo_complete() "--wp") if [ "${COMP_WORDS[1]}" != "debug" ]; then if [ "${COMP_WORDS[2]}" == "create" ]; then - retlist="--wp --wpsc --wpfc --user --email --pass --wpredis --wprocket --wpce --letsencrypt -le --letsencrypt=wildcard --dns --dns=dns_cf --dns=dns_dgon --php72 --php73 --php74 --php80 --php81" + retlist="--wp --wpsc --wpfc --user --email --pass --wpredis --wprocket --wpce --letsencrypt -le --letsencrypt=wildcard --dns --dns=dns_cf --dns=dns_dgon --php72 --php73 --php74 --php80 --php81 --php82" elif [ "${COMP_WORDS[2]}" == "update" ]; then - retlist="--wp --wpfc --wpsc --php72 --php73 --php74 --php80 --php81 --wpredis --wprocket --wpce -le --letsencrypt --letsencrypt=wildcard -le=wildcard --dns --dns=dns_cf --dns=dns_dgon" + retlist="--wp --wpfc --wpsc --php72 --php73 --php74 --php80 --php81 --php82 --wpredis --wprocket --wpce -le --letsencrypt --letsencrypt=wildcard -le=wildcard --dns --dns=dns_cf --dns=dns_dgon" else retlist="" fi @@ -230,9 +230,9 @@ _wo_complete() "--wpsubdir" | "--wpsubdomain") if [ "${COMP_WORDS[1]}" != "debug" ]; then if [ "${COMP_WORDS[2]}" == "create" ]; then - retlist="--wpsc --wpfc --user --email --pass --wpredis --wprocket --wpce -le -le=wildcard --letsencrypt --letsencrypt=wildcard --php72 --php73 --php74 --php80 --php81 --dns --dns=dns_cf --dns=dns_dgon" + retlist="--wpsc --wpfc --user --email --pass --wpredis --wprocket --wpce -le -le=wildcard --letsencrypt --letsencrypt=wildcard --php72 --php73 --php74 --php80 --php81 --php82 --dns --dns=dns_cf --dns=dns_dgon" elif [ "${COMP_WORDS[2]}" == "update" ]; then - retlist="--wpfc --wpsc --php72 --php73 --php74 --php80 --php81 --wpredis --wprocket --wpce -le -le=wildcard --letsencrypt --letsencrypt=wildcard --dns --dns=dns_cf --dns=dns_dgon" + retlist="--wpfc --wpsc --php72 --php73 --php74 --php80 --php81 --php82 --wpredis --wprocket --wpce -le -le=wildcard --letsencrypt --letsencrypt=wildcard --dns --dns=dns_cf --dns=dns_dgon" else retlist="" fi @@ -248,7 +248,7 @@ _wo_complete() "--wpredis" | "--wprocket" | "--wpce" | "--wpfc" | "--wpsc" | "--wpsubdir" | "--wpsubdomain" | "--user" | "--pass" | "--email" | "--wp") if [ "${COMP_WORDS[2]}" == "create" ]; then - retlist="--user --pass --email --wp --wpsubdir --wpsubdomain --wpfc --wpsc --wpredis --wprocket --wpce --php72 --php73 --php74 --php80 --php81 -le -le=wildcard --letsencrypt --letsencrypt=wildcard --dns --dns=dns_cf --dns=dns_dgon" + retlist="--user --pass --email --wp --wpsubdir --wpsubdomain --wpfc --wpsc --wpredis --wprocket --wpce --php72 --php73 --php74 --php80 --php81 --php82 -le -le=wildcard --letsencrypt --letsencrypt=wildcard --dns --dns=dns_cf --dns=dns_dgon" else retlist="" fi @@ -261,7 +261,7 @@ _wo_complete() "--wpredis" | "--wprocket" | "--wpce" | "--wpfc" | "--wpsc") if [ "${COMP_WORDS[2]}" == "update" ]; then - retlist="--password --php72 --php73 --php74 --php80 --php81 --mysql --wp --wpsubdir --wpsubdomain -le --letsencrypt --dns --dns=dns_cf --dns=dns_dgon" + retlist="--password --php72 --php73 --php74 --php80 --php81 --php82 --mysql --wp --wpsubdir --wpsubdomain -le --letsencrypt --dns --dns=dns_cf --dns=dns_dgon" else retlist="" fi @@ -272,11 +272,11 @@ _wo_complete() -- $cur) ) ;; - "--web" | "--admin" | "--nginx" | "--php" | "--php73" | "--php74" | "--php80" | "--php81" | "--mysql" | "--wpcli" | "--phpmyadmin" | "--adminer" | "--utils" | "--fail2ban" | "--ufw" | "--redis" | "--phpredisadmin" | "--netdata" | "--sendmail" | "--composer" | "--proftpd" | "--cheat" | "--nanorc" | "--clamav" | "--dashboard") + "--web" | "--admin" | "--nginx" | "--php" | "--php73" | "--php74" | "--php80" | "--php81" | "--php82" | "--mysql" | "--wpcli" | "--phpmyadmin" | "--adminer" | "--utils" | "--fail2ban" | "--ufw" | "--redis" | "--phpredisadmin" | "--netdata" | "--sendmail" | "--composer" | "--proftpd" | "--cheat" | "--nanorc" | "--clamav" | "--dashboard") if [[ "${COMP_WORDS[2]}" == "install" || "${COMP_WORDS[2]}" == "purge" || "${COMP_WORDS[2]}" == "remove" ]]; then - retlist="--web --admin --security --nginx --php --php73 --php74 --php80 --php81 --mysql --wpcli --phpmyadmin --adminer --utils --redis --fail2ban --ufw --phpredisadmin --netdata --force" + retlist="--web --admin --security --nginx --php --php73 --php74 --php80 --php81 --php82 --mysql --wpcli --phpmyadmin --adminer --utils --redis --fail2ban --ufw --phpredisadmin --netdata --force" elif [[ "${COMP_WORDS[2]}" == "start" || "${COMP_WORDS[2]}" == "reload" || "${COMP_WORDS[2]}" == "restart" || "${COMP_WORDS[2]}" == "stop" ]]; then - retlist="--nginx --php --php73 --php74 --php80 --php81 --mysql --redis --netdata --fail2ban --ufw" + retlist="--nginx --php --php73 --php74 --php80 --php81 --php82 --mysql --redis --netdata --fail2ban --ufw" elif [[ "${COMP_WORDS[1]}" == "debug" ]]; then retlist="--start --nginx --php --php73 --fpm --fpm7 --mysql -i --interactive -stop --import-slow-log --import-slow-log-interval= -" if [[ $prev == '--mysql' ]]; then @@ -363,7 +363,7 @@ _wo_complete() case "$mprev" in "--user" | "--email" | "--pass") if [ "${COMP_WORDS[2]}" == "create" ]; then - retlist="--user --pass --email --html --php --php73 --php74 --php80 --php81 --mysql --wp --wpsubdir --wpsubdomain --wpfc --wpsc --wpredis --wprocket --wpce -le -le=wildcard --letsencrypt --letsencrypt=wildcard --dns --dns=dns_cf --dns=dns_dgon" + retlist="--user --pass --email --html --php --php73 --php74 --php80 --php81 --php82 --mysql --wp --wpsubdir --wpsubdomain --wpfc --wpsc --wpredis --wprocket --wpce -le -le=wildcard --letsencrypt --letsencrypt=wildcard --dns --dns=dns_cf --dns=dns_dgon" fi ret="${retlist[@]/$prev}" COMPREPLY=( $(compgen \ diff --git a/tests/travis.sh b/tests/travis.sh index 62a0afa..45e18c5 100644 --- a/tests/travis.sh +++ b/tests/travis.sh @@ -32,9 +32,9 @@ echo -e "${CGREEN}#############################################${CEND}" echo -e ' stack install ' echo -e "${CGREEN}#############################################${CEND}" if [ "$wo_distro" != "xenial" ]; then -stack_list='nginx php php73 php74 php80 php81 mysql redis fail2ban clamav proftpd netdata phpmyadmin composer dashboard extplorer adminer redis sendmail phpredisadmin mysqltuner utils ufw cheat nanorc' +stack_list='nginx php php73 php74 php80 php81 php82 mysql redis fail2ban clamav proftpd netdata phpmyadmin composer dashboard extplorer adminer redis sendmail phpredisadmin mysqltuner utils ufw cheat nanorc' else -stack_list='nginx php php73 php74 php80 php81 mysql redis fail2ban clamav proftpd netdata phpmyadmin composer dashboard extplorer adminer redis phpredisadmin mysqltuner utils ufw cheat nanorc' +stack_list='nginx php php73 php74 php80 php81 php82 mysql redis fail2ban clamav proftpd netdata phpmyadmin composer dashboard extplorer adminer redis phpredisadmin mysqltuner utils ufw cheat nanorc' fi for stack in $stack_list; do echo -ne " Installing $stack [..]\r" @@ -54,7 +54,7 @@ done echo -e "${CGREEN}#############################################${CEND}" echo -e ' Simple site create ' echo -e "${CGREEN}#############################################${CEND}" -site_types='html php php72 php73 php74 php80 php81 mysql wp wpfc wpsc wpredis wpce wprocket wpsubdomain wpsubdir ngxblocker' +site_types='html php php72 php73 php74 php80 php81 php82 mysql wp wpfc wpsc wpredis wpce wprocket wpsubdomain wpsubdir ngxblocker' for site in $site_types; do echo -ne " Creating $site [..]\r" if { @@ -194,6 +194,27 @@ done echo echo -e "${CGREEN}#############################################${CEND}" echo +echo -e "${CGREEN}#############################################${CEND}" +echo -e ' wo site update --php82 ' +echo -e "${CGREEN}#############################################${CEND}" +other_site_types='mysql php72 php73 wp wpfc wpsc wpredis wpce wprocket wpsubdomain wpsubdir' +for site in $other_site_types; do + echo -ne " Updating site to $site php82 [..]\r" + if { + wo site update ${site}.net --php81 + } >>/var/log/wo/test.log; then + echo -ne " Updating site to $site php82 [${CGREEN}OK${CEND}]\\r" + echo -ne '\n' + else + echo -e " Updating site to $site php82 [${CRED}FAIL${CEND}]" + echo -ne '\n' + exit_script + + fi +done +echo +echo -e "${CGREEN}#############################################${CEND}" +echo wo site info wp.net echo echo -e "${CGREEN}#############################################${CEND}" @@ -260,7 +281,7 @@ if [ -z "$1" ]; then echo -e "${CGREEN}#############################################${CEND}" echo -e ' wo stack upgrade ' echo -e "${CGREEN}#############################################${CEND}" - stack_upgrade='nginx php php72 php73 php74 php80 php81 mysql redis netdata dashboard phpmyadmin adminer fail2ban composer ngxblocker mysqltuner' + stack_upgrade='nginx php php72 php73 php74 php80 php81 php82 mysql redis netdata dashboard phpmyadmin adminer fail2ban composer ngxblocker mysqltuner' for stack in $stack_upgrade; do echo -ne " Upgrading $stack [..]\r" if { @@ -407,7 +428,7 @@ wo info echo -e "${CGREEN}#############################################${CEND}" echo -e ' wo stack purge ' echo -e "${CGREEN}#############################################${CEND}" -stack_purge='nginx php php73 php74 php80 php81 mysql redis fail2ban clamav proftpd netdata phpmyadmin composer dashboard extplorer adminer redis ufw ngxblocker cheat nanorc' +stack_purge='nginx php php73 php74 php80 php81 php82 mysql redis fail2ban clamav proftpd netdata phpmyadmin composer dashboard extplorer adminer redis ufw ngxblocker cheat nanorc' for stack in $stack_purge; do echo -ne " purging $stack [..]\r" if { diff --git a/wo/cli/plugins/info.py b/wo/cli/plugins/info.py index a463f0d..85fb5b8 100644 --- a/wo/cli/plugins/info.py +++ b/wo/cli/plugins/info.py @@ -41,6 +41,9 @@ class WOInfoController(CementBaseController): (['--php81'], dict(help='Get PHP 8.1 configuration information', action='store_true')), + (['--php82'], + dict(help='Get PHP 8.2 configuration information', + action='store_true')), (['--nginx'], dict(help='Get Nginx configuration information', action='store_true')), @@ -508,6 +511,93 @@ class WOInfoController(CementBaseController): debug_xdebug_profiler_enable_trigger=debug_xdebug) self.app.render((data), 'info_php.mustache') + @expose(hide=True) + def info_php82(self): + """Display PHP information""" + version = os.popen("/usr/bin/php8.2 -v 2>/dev/null | " + "head -n1 | cut -d' ' -f2 |" + " cut -d'+' -f1 | tr -d '\n'").read + config = configparser.ConfigParser() + config.read('/etc/php/8.2/fpm/php.ini') + expose_php = config['PHP']['expose_php'] + memory_limit = config['PHP']['memory_limit'] + post_max_size = config['PHP']['post_max_size'] + upload_max_filesize = config['PHP']['upload_max_filesize'] + max_execution_time = config['PHP']['max_execution_time'] + + if os.path.exists('/etc/php/8.2/fpm/pool.d/www.conf'): + config.read('/etc/php/8.2/fpm/pool.d/www.conf') + else: + Log.error(self, 'php-fpm pool config not found') + if config.has_section('www'): + wconfig = config['www'] + elif config.has_section('www-php82'): + wconfig = config['www-php82'] + else: + Log.error(self, 'Unable to parse configuration') + www_listen = wconfig['listen'] + www_ping_path = wconfig['ping.path'] + www_pm_status_path = wconfig['pm.status_path'] + www_pm = wconfig['pm'] + www_pm_max_requests = wconfig['pm.max_requests'] + www_pm_max_children = wconfig['pm.max_children'] + www_pm_start_servers = wconfig['pm.start_servers'] + www_pm_min_spare_servers = wconfig['pm.min_spare_servers'] + www_pm_max_spare_servers = wconfig['pm.max_spare_servers'] + www_request_terminate_time = (wconfig + ['request_terminate_timeout']) + try: + www_xdebug = (wconfig + ['php_admin_flag[xdebug.profiler_enable' + '_trigger]']) + except Exception as e: + Log.debug(self, "{0}".format(e)) + www_xdebug = 'off' + + config.read('/etc/php/8.2/fpm/pool.d/debug.conf') + debug_listen = config['debug']['listen'] + debug_ping_path = config['debug']['ping.path'] + debug_pm_status_path = config['debug']['pm.status_path'] + debug_pm = config['debug']['pm'] + debug_pm_max_requests = config['debug']['pm.max_requests'] + debug_pm_max_children = config['debug']['pm.max_children'] + debug_pm_start_servers = config['debug']['pm.start_servers'] + debug_pm_min_spare_servers = config['debug']['pm.min_spare_servers'] + debug_pm_max_spare_servers = config['debug']['pm.max_spare_servers'] + debug_request_terminate = (config['debug'] + ['request_terminate_timeout']) + try: + debug_xdebug = (config['debug']['php_admin_flag[xdebug.profiler_' + 'enable_trigger]']) + except Exception as e: + Log.debug(self, "{0}".format(e)) + debug_xdebug = 'off' + + data = dict(version=version, expose_php=expose_php, + memory_limit=memory_limit, post_max_size=post_max_size, + upload_max_filesize=upload_max_filesize, + max_execution_time=max_execution_time, + www_listen=www_listen, www_ping_path=www_ping_path, + www_pm_status_path=www_pm_status_path, www_pm=www_pm, + www_pm_max_requests=www_pm_max_requests, + www_pm_max_children=www_pm_max_children, + www_pm_start_servers=www_pm_start_servers, + www_pm_min_spare_servers=www_pm_min_spare_servers, + www_pm_max_spare_servers=www_pm_max_spare_servers, + www_request_terminate_timeout=www_request_terminate_time, + www_xdebug_profiler_enable_trigger=www_xdebug, + debug_listen=debug_listen, debug_ping_path=debug_ping_path, + debug_pm_status_path=debug_pm_status_path, + debug_pm=debug_pm, + debug_pm_max_requests=debug_pm_max_requests, + debug_pm_max_children=debug_pm_max_children, + debug_pm_start_servers=debug_pm_start_servers, + debug_pm_min_spare_servers=debug_pm_min_spare_servers, + debug_pm_max_spare_servers=debug_pm_max_spare_servers, + debug_request_terminate_timeout=debug_request_terminate, + debug_xdebug_profiler_enable_trigger=debug_xdebug) + self.app.render((data), 'info_php.mustache') + @expose(hide=True) def info_mysql(self): """Display MySQL information""" @@ -549,7 +639,7 @@ class WOInfoController(CementBaseController): if (not pargs.nginx and not pargs.php and not pargs.mysql and not pargs.php73 and not pargs.php74 and not pargs.php80 and - not pargs.php81): + not pargs.php81 and not pargs.php82): pargs.nginx = True pargs.php = True pargs.mysql = True @@ -561,6 +651,8 @@ class WOInfoController(CementBaseController): pargs.php80 = True if WOAptGet.is_installed(self, 'php8.1-fpm'): pargs.php81 = True + if WOAptGet.is_installed(self, 'php8.2-fpm'): + pargs.php82 = True if pargs.nginx: if ((not WOAptGet.is_installed(self, 'nginx-custom')) and @@ -599,6 +691,12 @@ class WOInfoController(CementBaseController): else: Log.info(self, "PHP 8.1 is not installed") + if pargs.php82: + if WOAptGet.is_installed(self, 'php8.2-fpm'): + self.info_php82() + else: + Log.info(self, "PHP 8.2 is not installed") + if pargs.mysql: if WOShellExec.cmd_exec(self, "/usr/bin/mysqladmin ping"): self.info_mysql() diff --git a/wo/cli/plugins/site_functions.py b/wo/cli/plugins/site_functions.py index b10f602..1e712c0 100644 --- a/wo/cli/plugins/site_functions.py +++ b/wo/cli/plugins/site_functions.py @@ -775,7 +775,8 @@ def sitebackup(self, data): .format(data['site_name']), backup_path) if data['currsitetype'] in ['html', 'php', 'php72', 'php74', - 'php73', 'php80', 'php81', 'proxy', 'mysql']: + 'php73', 'php80', 'php81', 'php82', + 'proxy', 'mysql']: if not data['wp']: Log.info(self, "Backing up Webroot \t\t", end='') WOFileUtils.copyfiles(self, wo_site_webroot + @@ -835,7 +836,7 @@ def site_package_check(self, stype): stack.app = self.app pargs = self.app.pargs if stype in ['html', 'proxy', 'php', 'php72', 'mysql', 'wp', 'wpsubdir', - 'wpsubdomain', 'php73', 'php74', 'php80', 'php81']: + 'wpsubdomain', 'php73', 'php74', 'php80', 'php81', 'php82']: Log.debug(self, "Setting apt_packages variable for Nginx") # Check if server has nginx-custom package @@ -873,19 +874,22 @@ def site_package_check(self, stype): if ((pargs.php and pargs.php73) or (pargs.php and pargs.php74) or (pargs.php and pargs.php72) or (pargs.php and pargs.php80) or - (pargs.php and pargs.php81) or - (pargs.php73 and pargs.php74) or (pargs.php72 and pargs.php73) or - (pargs.php72 and pargs.php74) or (pargs.php73 and pargs.php80) or - (pargs.php74 and pargs.php80) or (pargs.php80 and pargs.php81) or + (pargs.php and pargs.php81) or (pargs.php and pargs.php82) or + (pargs.php72 and pargs.php73) or (pargs.php72 and pargs.php74) or (pargs.php72 and pargs.php80) or (pargs.php72 and pargs.php81) or - (pargs.php73 and pargs.php81) or (pargs.php74 and pargs.php81) or - (pargs.php80 and pargs.php81)): + (pargs.php72 and pargs.php82) or + (pargs.php73 and pargs.php74) or (pargs.php73 and pargs.php80) or + (pargs.php73 and pargs.php81) or (pargs.php73 and pargs.php82) or + (pargs.php74 and pargs.php80) or (pargs.php74 and pargs.php81) or + (pargs.php74 and pargs.php82) or + (pargs.php80 and pargs.php81) or (pargs.php80 and pargs.php82) or + (pargs.php81 and pargs.php82)): Log.error( self, "Error: two different PHP versions cannot be " "combined within the same WordOps site") if ((not pargs.php72) and (not pargs.php73) and (not pargs.php74) and - (not pargs.php80) and (not pargs.php81) and + (not pargs.php80) and (not pargs.php81) and (not pargs.php82) and stype in ['php', 'mysql', 'wp', 'wpsubdir', 'wpsubdomain']): Log.debug(self, "Setting apt_packages variable for PHP") @@ -909,12 +913,15 @@ def site_package_check(self, stype): elif config_php_ver == '8.1': php_check = 'php8.1-fpm' php_to_setup = WOVar.wo_php81 + elif config_php_ver == '8.2': + php_check = 'php8.2-fpm' + php_to_setup = WOVar.wo_php82 else: - php_check = 'php8.0-fpm' - php_to_setup = WOVar.wo_php80 + php_check = 'php8.1-fpm' + php_to_setup = WOVar.wo_php81 else: - php_check = 'php8.0-fpm' - php_to_setup = WOVar.wo_php80 + php_check = 'php8.1-fpm' + php_to_setup = WOVar.wo_php81 if not (WOAptGet.is_installed(self, php_check)): apt_packages = apt_packages + php_to_setup + WOVar.wo_php_extra @@ -949,6 +956,12 @@ def site_package_check(self, stype): if not WOAptGet.is_installed(self, 'php8.1-fpm'): apt_packages = apt_packages + WOVar.wo_php81 + WOVar.wo_php_extra + if pargs.php82 and stype in ['php82', 'mysql', 'wp', + 'wpsubdir', 'wpsubdomain']: + Log.debug(self, "Setting apt_packages variable for PHP 8.2") + if not WOAptGet.is_installed(self, 'php8.2-fpm'): + apt_packages = apt_packages + WOVar.wo_php82 + WOVar.wo_php_extra + if stype in ['mysql', 'wp', 'wpsubdir', 'wpsubdomain']: Log.debug(self, "Setting apt_packages variable for MySQL") if not WOShellExec.cmd_exec(self, "/usr/bin/mysqladmin ping"): @@ -1130,7 +1143,7 @@ def detSitePar(opts): for key, val in opts.items(): if val and key in ['html', 'php', 'mysql', 'wp', 'wpsubdir', 'wpsubdomain', 'php72', - 'php73', 'php74', 'php80', 'php81']: + 'php73', 'php74', 'php80', 'php81', 'php82', ]: typelist.append(key) elif val and key in ['wpfc', 'wpsc', 'wpredis', 'wprocket', 'wpce']: cachelist.append(key) @@ -1176,6 +1189,12 @@ def detSitePar(opts): cachetype = 'basic' else: cachetype = cachelist[0] + elif False not in [x in ('php82', 'mysql', 'html') for x in typelist]: + sitetype = 'mysql' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] elif False not in [x in ('php', 'mysql') for x in typelist]: sitetype = 'mysql' if not cachelist: @@ -1212,6 +1231,12 @@ def detSitePar(opts): cachetype = 'basic' else: cachetype = cachelist[0] + elif False not in [x in ('php82', 'mysql') for x in typelist]: + sitetype = 'mysql' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] elif False not in [x in ('html', 'mysql') for x in typelist]: sitetype = 'mysql' if not cachelist: @@ -1266,6 +1291,12 @@ def detSitePar(opts): cachetype = 'basic' else: cachetype = cachelist[0] + elif False not in [x in ('wp', 'php82') for x in typelist]: + sitetype = 'wp' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] elif False not in [x in ('wpsubdir', 'php72') for x in typelist]: sitetype = 'wpsubdir' if not cachelist: @@ -1296,6 +1327,12 @@ def detSitePar(opts): cachetype = 'basic' else: cachetype = cachelist[0] + elif False not in [x in ('wpsubdir', 'php82') for x in typelist]: + sitetype = 'wpsubdir' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] elif False not in [x in ('wpsubdomain', 'php72') for x in typelist]: sitetype = 'wpsubdomain' if not cachelist: @@ -1326,6 +1363,12 @@ def detSitePar(opts): cachetype = 'basic' else: cachetype = cachelist[0] + elif False not in [x in ('wpsubdomain', 'php82') for x in typelist]: + sitetype = 'wpsubdomain' + if not cachelist: + cachetype = 'basic' + else: + cachetype = cachelist[0] else: raise RuntimeError("could not determine site and cache type") else: @@ -1347,6 +1390,9 @@ def detSitePar(opts): elif (not typelist or "php81" in typelist) and cachelist: sitetype = 'wp' cachetype = cachelist[0] + elif (not typelist or "php82" in typelist) and cachelist: + sitetype = 'wp' + cachetype = cachelist[0] elif typelist and (not cachelist): sitetype = typelist[0] cachetype = 'basic' diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index 28a69b0..da2ca24 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -51,6 +51,8 @@ class WOStackController(CementBaseController): dict(help='Install PHP 8.0 stack', action='store_true')), (['--php81'], dict(help='Install PHP 8.1 stack', action='store_true')), + (['--php82'], + dict(help='Install PHP 8.2 stack', action='store_true')), (['--mysql'], dict(help='Install MySQL stack', action='store_true')), (['--mariadb'], @@ -121,7 +123,7 @@ class WOStackController(CementBaseController): # Default action for stack installation if not (pargs.web or pargs.admin or pargs.nginx or pargs.php or pargs.php72 or pargs.php73 or pargs.php74 or - pargs.php80 or pargs.php81 or + pargs.php80 or pargs.php81 or pargs.php82 or pargs.mysql or pargs.wpcli or pargs.phpmyadmin or pargs.composer or pargs.netdata or pargs.composer or pargs.dashboard or pargs.fail2ban or pargs.security or @@ -149,6 +151,7 @@ class WOStackController(CementBaseController): pargs.php74 = True pargs.php80 = True pargs.php81 = True + pargs.php82 = True pargs.redis = True pargs.proftpd = True @@ -166,8 +169,10 @@ class WOStackController(CementBaseController): pargs.php80 = True elif config_php_ver == '8.1': pargs.php81 = True + elif config_php_ver == '8.2': + pargs.php82 = True else: - pargs.php80 = True + pargs.php81 = True pargs.nginx = True pargs.mysql = True pargs.wpcli = True @@ -257,6 +262,16 @@ class WOStackController(CementBaseController): Log.debug(self, "PHP 8.1 already installed") Log.info(self, "PHP 8.1 already installed") + # PHP 8.2 + if pargs.php82: + Log.debug(self, "Setting apt_packages variable for PHP 8.2") + if not WOAptGet.is_installed(self, 'php8.2-fpm'): + apt_packages = (apt_packages + WOVar.wo_php82 + + WOVar.wo_php_extra) + else: + Log.debug(self, "PHP 8.2 already installed") + Log.info(self, "PHP 8.2 already installed") + # MariaDB 10.3 if pargs.mysql: pargs.mysqltuner = True @@ -512,7 +527,8 @@ class WOStackController(CementBaseController): WOAptGet.is_installed(self, 'php7.3-fpm') or WOAptGet.is_installed(self, 'php7.4-fpm') or WOAptGet.is_installed(self, 'php8.0-fpm') or - WOAptGet.is_installed(self, 'php8.1-fpm')): + WOAptGet.is_installed(self, 'php8.1-fpm') or + WOAptGet.is_installed(self, 'php8.2-fpm')): pargs.php80 = True Log.debug(self, "Setting packages variable for utils") packages = packages + [[ @@ -610,7 +626,7 @@ class WOStackController(CementBaseController): (not pargs.phpredisadmin) and (not pargs.sendmail) and (not pargs.php73) and (not pargs.php74) and (not pargs.php72) and (not pargs.php80) and - (not pargs.php81) and (not pargs.all)): + (not pargs.php81) and (not pargs.php82) and (not pargs.all)): self.app.args.print_help() if pargs.php: @@ -666,7 +682,8 @@ class WOStackController(CementBaseController): if not (WOAptGet.is_installed(self, 'php7.3-fpm') or WOAptGet.is_installed(self, 'php7.4-fpm') or WOAptGet.is_installed(self, 'php8.0-fpm') or - WOAptGet.is_installed(self, 'php8.1-fpm')): + WOAptGet.is_installed(self, 'php8.1-fpm') or + WOAptGet.is_installed(self, 'php8.2-fpm')): apt_packages = apt_packages + WOVar.wo_php_extra else: Log.debug(self, "PHP 7.2 is not installed") @@ -680,7 +697,8 @@ class WOStackController(CementBaseController): if not (WOAptGet.is_installed(self, 'php7.2-fpm') or WOAptGet.is_installed(self, 'php7.4-fpm') or WOAptGet.is_installed(self, 'php8.0-fpm') or - WOAptGet.is_installed(self, 'php8.1-fpm')): + WOAptGet.is_installed(self, 'php8.1-fpm') or + WOAptGet.is_installed(self, 'php8.2-fpm')): apt_packages = apt_packages + WOVar.wo_php_extra else: Log.debug(self, "PHP 7.3 is not installed") @@ -694,7 +712,8 @@ class WOStackController(CementBaseController): if not (WOAptGet.is_installed(self, 'php7.3-fpm') or WOAptGet.is_installed(self, 'php7.2-fpm') or WOAptGet.is_installed(self, 'php8.0-fpm') or - WOAptGet.is_installed(self, 'php8.1-fpm')): + WOAptGet.is_installed(self, 'php8.1-fpm') or + WOAptGet.is_installed(self, 'php8.2-fpm')): apt_packages = apt_packages + WOVar.wo_php_extra else: Log.debug(self, "PHP 7.4 is not installed") @@ -708,7 +727,8 @@ class WOStackController(CementBaseController): if not (WOAptGet.is_installed(self, 'php7.3-fpm') or WOAptGet.is_installed(self, 'php7.2-fpm') or WOAptGet.is_installed(self, 'php7.4-fpm') or - WOAptGet.is_installed(self, 'php8.1-fpm')): + WOAptGet.is_installed(self, 'php8.1-fpm') or + WOAptGet.is_installed(self, 'php8.2-fpm')): apt_packages = apt_packages + WOVar.wo_php_extra else: Log.debug(self, "PHP 8.0 is not installed") @@ -722,12 +742,30 @@ class WOStackController(CementBaseController): if not (WOAptGet.is_installed(self, 'php7.3-fpm') or WOAptGet.is_installed(self, 'php7.2-fpm') or WOAptGet.is_installed(self, 'php7.4-fpm') or - WOAptGet.is_installed(self, 'php8.0-fpm')): + WOAptGet.is_installed(self, 'php8.0-fpm') or + WOAptGet.is_installed(self, 'php8.1-fpm') or + WOAptGet.is_installed(self, 'php8.2-fpm')): apt_packages = apt_packages + WOVar.wo_php_extra else: Log.debug(self, "PHP 8.1 is not installed") Log.info(self, "PHP 8.1 is not installed") + # PHP 8.2 + if pargs.php82: + Log.debug(self, "Setting apt_packages variable for PHP 8.2") + if WOAptGet.is_installed(self, 'php8.2-fpm'): + apt_packages = apt_packages + WOVar.wo_php82 + if not (WOAptGet.is_installed(self, 'php7.3-fpm') or + WOAptGet.is_installed(self, 'php7.2-fpm') or + WOAptGet.is_installed(self, 'php7.4-fpm') or + WOAptGet.is_installed(self, 'php8.0-fpm') or + WOAptGet.is_installed(self, 'php8.1-fpm') or + WOAptGet.is_installed(self, 'php8.2-fpm')): + apt_packages = apt_packages + WOVar.wo_php_extra + else: + Log.debug(self, "PHP 8.2 is not installed") + Log.info(self, "PHP 8.2 is not installed") + # REDIS if pargs.redis: if WOAptGet.is_installed(self, 'redis-server'): @@ -961,12 +999,13 @@ class WOStackController(CementBaseController): (not pargs.ufw) and (not pargs.ngxblocker) and (not pargs.phpredisadmin) and (not pargs.sendmail) and (not pargs.php80) and (not pargs.php81) and + (not pargs.php82) and (not pargs.php73) and (not pargs.php74) and (not pargs.php72) and (not pargs.all)): self.app.args.print_help() if pargs.php: - pargs.php72 = True + pargs.php81 = True if pargs.mariadb: pargs.mysql = True @@ -974,10 +1013,12 @@ class WOStackController(CementBaseController): if pargs.all: pargs.web = True pargs.admin = True + pargs.php72 = True pargs.php73 = True pargs.php74 = True pargs.php80 = True pargs.php81 = True + pargs.php82 = True pargs.fail2ban = True pargs.proftpd = True pargs.utils = True @@ -1033,7 +1074,8 @@ class WOStackController(CementBaseController): if not (WOAptGet.is_installed(self, 'php7.2-fpm') or WOAptGet.is_installed(self, 'php7.4-fpm') or WOAptGet.is_installed(self, 'php8.0-fpm') or - WOAptGet.is_installed(self, 'php8.1-fpm')): + WOAptGet.is_installed(self, 'php8.1-fpm') or + WOAptGet.is_installed(self, 'php8.2-fpm')): apt_packages = apt_packages + WOVar.wo_php_extra else: Log.debug(self, "PHP 7.3 is not installed") @@ -1047,7 +1089,8 @@ class WOStackController(CementBaseController): if not (WOAptGet.is_installed(self, 'php7.3-fpm') or WOAptGet.is_installed(self, 'php7.2-fpm') or WOAptGet.is_installed(self, 'php8.0-fpm') or - WOAptGet.is_installed(self, 'php8.1-fpm')): + WOAptGet.is_installed(self, 'php8.1-fpm') or + WOAptGet.is_installed(self, 'php8.2-fpm')): apt_packages = apt_packages + WOVar.wo_php_extra else: Log.debug(self, "PHP 7.4 is not installed") @@ -1061,7 +1104,8 @@ class WOStackController(CementBaseController): if not (WOAptGet.is_installed(self, 'php7.3-fpm') or WOAptGet.is_installed(self, 'php7.2-fpm') or WOAptGet.is_installed(self, 'php7.4-fpm') or - WOAptGet.is_installed(self, 'php8.1-fpm')): + WOAptGet.is_installed(self, 'php8.1-fpm') or + WOAptGet.is_installed(self, 'php8.2-fpm')): apt_packages = apt_packages + WOVar.wo_php_extra else: Log.debug(self, "PHP 8.0 is not installed") @@ -1075,12 +1119,33 @@ class WOStackController(CementBaseController): if not (WOAptGet.is_installed(self, 'php7.3-fpm') or WOAptGet.is_installed(self, 'php7.2-fpm') or WOAptGet.is_installed(self, 'php8.0-fpm') or - WOAptGet.is_installed(self, 'php7.4-fpm')): + WOAptGet.is_installed(self, 'php7.4-fpm') or + WOAptGet.is_installed(self, 'php8.2-fpm')): apt_packages = apt_packages + WOVar.wo_php_extra else: Log.debug(self, "PHP 8.1 is not installed") Log.info(self, "PHP 8.1 is not installed") + Log.info(self, "PHP 8.1 is not installed") + + # PHP 8.2 + if pargs.php82: + Log.debug(self, "Setting apt_packages variable for PHP 8.2") + if WOAptGet.is_installed(self, 'php8.2-fpm'): + apt_packages = apt_packages + WOVar.wo_php74 + if not (WOAptGet.is_installed(self, 'php7.3-fpm') or + WOAptGet.is_installed(self, 'php7.2-fpm') or + WOAptGet.is_installed(self, 'php8.0-fpm') or + WOAptGet.is_installed(self, 'php7.4-fpm') or + WOAptGet.is_installed(self, 'php8.0-fpm') or + WOAptGet.is_installed(self, 'php8.1-fpm')): + apt_packages = apt_packages + WOVar.wo_php_extra + else: + Log.debug(self, "PHP 8.2 is not installed") + Log.info(self, "PHP 8.2 is not installed") + + Log.info(self, "PHP 8.2 is not installed") + # REDIS if pargs.redis: if WOAptGet.is_installed(self, 'redis-server'): diff --git a/wo/cli/plugins/stack_pref.py b/wo/cli/plugins/stack_pref.py index fcb236b..424b869 100644 --- a/wo/cli/plugins/stack_pref.py +++ b/wo/cli/plugins/stack_pref.py @@ -81,8 +81,11 @@ def pre_pref(self, apt_packages): # add php repository if (('php7.3-fpm' in apt_packages) or - ('php7.2-fpm' in apt_packages) or ('php7.4-fpm' in apt_packages) or - ('php8.0-fpm' in apt_packages) or ('php8.1-fpm' in apt_packages)): + ('php7.2-fpm' in apt_packages) or + ('php7.4-fpm' in apt_packages) or + ('php8.0-fpm' in apt_packages) or + ('php8.1-fpm' in apt_packages) or + ('php8.2-fpm' in apt_packages)): if (WOVar.wo_distro == 'ubuntu'): Log.debug(self, 'Adding ppa for PHP') Log.info(self, "Adding repository for PHP, please wait...") @@ -221,7 +224,13 @@ def post_pref(self, apt_packages, packages, upgrade=False): .format(ngxcom), 'wpsubdir.mustache', data) - wo_php_version = ["php72", "php73", "php74", "php80" "php81"] + wo_php_version = ["php72", + "php73", + "php74", + "php80", + "php81", + "php82", + ] for wo_php in wo_php_version: data = dict(upstream="{0}".format(wo_php), release=WOVar.wo_version) @@ -1068,7 +1077,7 @@ def post_pref(self, apt_packages, packages, upgrade=False): if os.path.exists('/etc/nginx/conf.d/upstream.conf'): if not WOFileUtils.grepcheck( - self, '/etc/nginx/conf.d/upstream.conf', 'php81'): + self, '/etc/nginx/conf.d/upstream.conf', 'php80'): data = dict(php="9000", debug="9001", php7="9070", debug7="9170", php8="9080", debug8="9180", @@ -1240,6 +1249,168 @@ def post_pref(self, apt_packages, packages, upgrade=False): 'upstream.mustache', data, True) WOConf.nginxcommon(self) + # php8.2 configuration + if set(WOVar.wo_php82).issubset(set(apt_packages)): + WOGit.add(self, ["/etc/php"], msg="Adding PHP into Git") + Log.info(self, "Configuring php8.2-fpm") + ngxroot = '/var/www/' + # Create log directories + if not os.path.exists('/var/log/php/8.2/'): + Log.debug(self, 'Creating directory /var/log/php/8.2/') + os.makedirs('/var/log/php/8.2/') + + if not os.path.isfile('/etc/php/8.2/fpm/php.ini.orig'): + WOFileUtils.copyfile(self, '/etc/php/8.2/fpm/php.ini', + '/etc/php/8.2/fpm/php.ini.orig') + + # Parse etc/php/8.2/fpm/php.ini + config = configparser.ConfigParser() + Log.debug(self, "configuring php file /etc/php/8.2/" + "fpm/php.ini") + config.read('/etc/php/8.2/fpm/php.ini.orig') + config['PHP']['expose_php'] = 'Off' + config['PHP']['post_max_size'] = '100M' + config['PHP']['upload_max_filesize'] = '100M' + config['PHP']['max_execution_time'] = '300' + config['PHP']['max_input_time'] = '300' + config['PHP']['max_input_vars'] = '20000' + config['Date']['date.timezone'] = WOVar.wo_timezone + config['opcache']['opcache.enable'] = '1' + config['opcache']['opcache.interned_strings_buffer'] = '8' + config['opcache']['opcache.max_accelerated_files'] = '10000' + config['opcache']['opcache.memory_consumption'] = '256' + config['opcache']['opcache.save_comments'] = '1' + config['opcache']['opcache.revalidate_freq'] = '5' + config['opcache']['opcache.consistency_checks'] = '0' + config['opcache']['opcache.validate_timestamps'] = '1' + config['opcache']['opcache.preload_user'] = 'www-data' + with open('/etc/php/8.2/fpm/php.ini', + encoding='utf-8', mode='w') as configfile: + Log.debug(self, "Writting php configuration into " + "/etc/php/8.2/fpm/php.ini") + config.write(configfile) + + # Render php-fpm pool template for php8.2 + data = dict(pid="/run/php/php8.2-fpm.pid", + error_log="/var/log/php8.2-fpm.log", + include="/etc/php/8.2/fpm/pool.d/*.conf") + WOTemplate.deploy( + self, '/etc/php/8.2/fpm/php-fpm.conf', + 'php-fpm.mustache', data) + + data = dict(pool='www-php82', listen='php82-fpm.sock', + user='www-data', + group='www-data', listenuser='root', + listengroup='www-data', openbasedir=True) + WOTemplate.deploy(self, '/etc/php/8.2/fpm/pool.d/www.conf', + 'php-pool.mustache', data) + data = dict(pool='www-two-php82', listen='php82-two-fpm.sock', + user='www-data', + group='www-data', listenuser='root', + listengroup='www-data', openbasedir=True) + WOTemplate.deploy(self, '/etc/php/8.2/fpm/pool.d/www-two.conf', + 'php-pool.mustache', data) + + # Generate /etc/php/8.2/fpm/pool.d/debug.conf + WOFileUtils.copyfile(self, "/etc/php/8.2/fpm/pool.d/www.conf", + "/etc/php/8.2/fpm/pool.d/debug.conf") + WOFileUtils.searchreplace(self, "/etc/php/8.2/fpm/pool.d/" + "debug.conf", "[www-php82]", "[debug]") + config = configparser.ConfigParser() + config.read('/etc/php/8.2/fpm/pool.d/debug.conf') + config['debug']['listen'] = '127.0.0.1:9182' + config['debug']['rlimit_core'] = 'unlimited' + config['debug']['slowlog'] = '/var/log/php/8.2/slow.log' + config['debug']['request_slowlog_timeout'] = '10s' + with open('/etc/php/8.2/fpm/pool.d/debug.conf', + encoding='utf-8', mode='w') as confifile: + Log.debug(self, "writting PHP 8.2 configuration into " + "/etc/php/8.2/fpm/pool.d/debug.conf") + config.write(confifile) + + with open("/etc/php/8.2/fpm/pool.d/debug.conf", + encoding='utf-8', mode='a') as myfile: + myfile.write( + "php_admin_value[xdebug.profiler_output_dir] " + "= /tmp/ \nphp_admin_value[xdebug.profiler_" + "output_name] = cachegrind.out.%p-%H-%R " + "\nphp_admin_flag[xdebug.profiler_enable" + "_trigger] = on \nphp_admin_flag[xdebug." + "profiler_enable] = off\n") + + # Disable xdebug + if not WOShellExec.cmd_exec( + self, "grep -q \';zend_extension\'" + " /etc/php/8.2/mods-available/xdebug.ini"): + WOFileUtils.searchreplace( + self, "/etc/php/8.2/mods-available/" + "xdebug.ini", + "zend_extension", ";zend_extension") + + # PHP and Debug pull configuration + if not os.path.exists('{0}22222/htdocs/fpm/status/' + .format(ngxroot)): + Log.debug(self, 'Creating directory ' + '{0}22222/htdocs/fpm/status/ ' + .format(ngxroot)) + os.makedirs('{0}22222/htdocs/fpm/status/' + .format(ngxroot)) + open('{0}22222/htdocs/fpm/status/debug82' + .format(ngxroot), + encoding='utf-8', mode='a').close() + open('{0}22222/htdocs/fpm/status/php82' + .format(ngxroot), + encoding='utf-8', mode='a').close() + + # Write info.php + if not os.path.exists('{0}22222/htdocs/php/' + .format(ngxroot)): + Log.debug(self, 'Creating directory ' + '{0}22222/htdocs/php/ ' + .format(ngxroot)) + os.makedirs('{0}22222/htdocs/php' + .format(ngxroot)) + + WOFileUtils.textwrite( + self, "{0}22222/htdocs/php/info.php" + .format(ngxroot), "") + + # write opcache clean for php82 + if not os.path.exists('{0}22222/htdocs/cache/opcache' + .format(ngxroot)): + os.makedirs('{0}22222/htdocs/cache/opcache' + .format(ngxroot)) + WOFileUtils.textwrite( + self, '{0}22222/htdocs/cache/opcache/php82.php' + .format(ngxroot), + '') + + WOFileUtils.chown(self, "{0}22222/htdocs" + .format(ngxroot), + 'www-data', + 'www-data', recursive=True) + + # enable imagick php extension + WOShellExec.cmd_exec(self, 'phpenmod -v ALL imagick') + + # check service restart or rollback configuration + if not WOService.restart_service(self, 'php8.2-fpm'): + WOGit.rollback(self, ["/etc/php"], msg="Rollback PHP") + else: + WOGit.add(self, ["/etc/php"], msg="Adding PHP into Git") + + if os.path.exists('/etc/nginx/conf.d/upstream.conf'): + if not WOFileUtils.grepcheck( + self, '/etc/nginx/conf.d/upstream.conf', 'php82'): + data = dict(php="9000", debug="9001", + php7="9070", debug7="9170", + php8="9080", debug8="9180", + release=WOVar.wo_version) + WOTemplate.deploy( + self, '/etc/nginx/conf.d/upstream.conf', + 'upstream.mustache', data, True) + WOConf.nginxcommon(self) + # create mysql config if it doesn't exist if "mariadb-server" in apt_packages: WOGit.add(self, ["/etc/mysql"], msg="Adding MySQL into Git") diff --git a/wo/cli/plugins/stack_services.py b/wo/cli/plugins/stack_services.py index 341eb9e..cc75408 100644 --- a/wo/cli/plugins/stack_services.py +++ b/wo/cli/plugins/stack_services.py @@ -26,6 +26,7 @@ class WOStackStatusController(CementBaseController): pargs.php74 or pargs.php80 or pargs.php81 or + pargs.php82 or pargs.mysql or pargs.redis or pargs.fail2ban or @@ -66,6 +67,10 @@ class WOStackStatusController(CementBaseController): services = services + ['php8.1-fpm'] else: Log.info(self, "PHP8.1-FPM is not installed") + if os.path.exists('{0}'.format(wo_system) + 'php8.2-fpm.service'): + services = services + ['php8.2-fpm'] + else: + Log.info(self, "PHP8.2-FPM is not installed") if pargs.php72: if os.path.exists('{0}'.format(wo_system) + 'php7.2-fpm.service'): @@ -97,6 +102,12 @@ class WOStackStatusController(CementBaseController): else: Log.info(self, "PHP8.1-FPM is not installed") + if pargs.php82: + if os.path.exists('{0}'.format(wo_system) + 'php8.2-fpm.service'): + services = services + ['php8.2-fpm'] + else: + Log.info(self, "PHP8.2-FPM is not installed") + if pargs.mysql: if ((WOVar.wo_mysql_host == "localhost") or (WOVar.wo_mysql_host == "127.0.0.1")): @@ -145,9 +156,9 @@ class WOStackStatusController(CementBaseController): services = [] wo_system = "/lib/systemd/system/" pargs = self.app.pargs - if not (pargs.nginx or pargs.php or - pargs.php72 or pargs.php73 or - pargs.php74 or pargs.php80 or pargs.php81 or + if not (pargs.nginx or + pargs.php or pargs.php72 or pargs.php73 or pargs.php74 or + pargs.php80 or pargs.php81 or pargs.php82 or pargs.mysql or pargs.fail2ban or pargs.netdata or @@ -207,6 +218,12 @@ class WOStackStatusController(CementBaseController): else: Log.info(self, "PHP8.1-FPM is not installed") + if pargs.php82: + if os.path.exists('{0}'.format(wo_system) + 'php8.2-fpm.service'): + services = services + ['php8.2-fpm'] + else: + Log.info(self, "PHP8.2-FPM is not installed") + if pargs.mysql: if ((WOVar.wo_mysql_host == "localhost") or (WOVar.wo_mysql_host == "127.0.0.1")): @@ -255,9 +272,9 @@ class WOStackStatusController(CementBaseController): services = [] wo_system = "/lib/systemd/system/" pargs = self.app.pargs - if not (pargs.nginx or pargs.php or - pargs.php72 or pargs.php73 or - pargs.php74 or pargs.php80 or pargs.php81 or + if not (pargs.nginx or + pargs.php or pargs.php72 or pargs.php73 or pargs.php74 or + pargs.php80 or pargs.php81 or pargs.php82 or pargs.mysql or pargs.netdata or pargs.proftpd or @@ -295,6 +312,10 @@ class WOStackStatusController(CementBaseController): services = services + ['php8.1-fpm'] else: Log.info(self, "PHP8.1-FPM is not installed") + if os.path.exists('{0}'.format(wo_system) + 'php8.2-fpm.service'): + services = services + ['php8.2-fpm'] + else: + Log.info(self, "PHP8.2-FPM is not installed") if pargs.php72: if os.path.exists('{0}'.format(wo_system) + 'php7.2-fpm.service'): @@ -326,6 +347,12 @@ class WOStackStatusController(CementBaseController): else: Log.info(self, "PHP8.1-FPM is not installed") + if pargs.php82: + if os.path.exists('{0}'.format(wo_system) + 'php8.2-fpm.service'): + services = services + ['php8.2-fpm'] + else: + Log.info(self, "PHP8.2-FPM is not installed") + if pargs.mysql: if ((WOVar.wo_mysql_host == "localhost") or (WOVar.wo_mysql_host == "127.0.0.1")): @@ -380,6 +407,7 @@ class WOStackStatusController(CementBaseController): pargs.php74 or pargs.php80 or pargs.php81 or + pargs.php82 or pargs.mysql or pargs.netdata or pargs.proftpd or @@ -419,6 +447,10 @@ class WOStackStatusController(CementBaseController): services = services + ['php8.1-fpm'] else: Log.info(self, "PHP8.1-FPM is not installed") + if os.path.exists('{0}'.format(wo_system) + 'php8.2-fpm.service'): + services = services + ['php8.2-fpm'] + else: + Log.info(self, "PHP8.2-FPM is not installed") if pargs.php72: if os.path.exists('{0}'.format(wo_system) + 'php7.2-fpm.service'): @@ -450,6 +482,12 @@ class WOStackStatusController(CementBaseController): else: Log.info(self, "PHP8.1-FPM is not installed") + if pargs.php82: + if os.path.exists('{0}'.format(wo_system) + 'php8.2-fpm.service'): + services = services + ['php8.2-fpm'] + else: + Log.info(self, "PHP8.2-FPM is not installed") + if pargs.mysql: if ((WOVar.wo_mysql_host == "localhost") or (WOVar.wo_mysql_host == "127.0.0.1")): @@ -510,8 +548,8 @@ class WOStackStatusController(CementBaseController): wo_system = "/lib/systemd/system/" pargs = self.app.pargs if not (pargs.nginx or pargs.php or - pargs.php72 or pargs.php73 or - pargs.php74 or pargs.php80 or pargs.php81 or + pargs.php72 or pargs.php73 or pargs.php74 or + pargs.php80 or pargs.php81 or pargs.php82 or pargs.mysql or pargs.netdata or pargs.proftpd or @@ -549,6 +587,10 @@ class WOStackStatusController(CementBaseController): services = services + ['php8.1-fpm'] else: Log.info(self, "PHP8.1-FPM is not installed") + if os.path.exists('{0}'.format(wo_system) + 'php8.2-fpm.service'): + services = services + ['php8.2-fpm'] + else: + Log.info(self, "PHP8.2-FPM is not installed") if pargs.php72: if os.path.exists('{0}'.format(wo_system) + 'php7.2-fpm.service'): @@ -580,6 +622,12 @@ class WOStackStatusController(CementBaseController): else: Log.info(self, "PHP8.1-FPM is not installed") + if pargs.php82: + if os.path.exists('{0}'.format(wo_system) + 'php8.2-fpm.service'): + services = services + ['php8.2-fpm'] + else: + Log.info(self, "PHP8.2-FPM is not installed") + if pargs.mysql: if ((WOVar.wo_mysql_host == "localhost") or (WOVar.wo_mysql_host == "127.0.0.1")): diff --git a/wo/cli/plugins/stack_upgrade.py b/wo/cli/plugins/stack_upgrade.py index b0333b2..a859d78 100644 --- a/wo/cli/plugins/stack_upgrade.py +++ b/wo/cli/plugins/stack_upgrade.py @@ -43,6 +43,8 @@ class WOStackUpgradeController(CementBaseController): dict(help='Upgrade PHP 8.0 stack', action='store_true')), (['--php81'], dict(help='Upgrade PHP 8.1 stack', action='store_true')), + (['--php82'], + dict(help='Upgrade PHP 8.2 stack', action='store_true')), (['--mysql'], dict(help='Upgrade MySQL stack', action='store_true')), (['--mariadb'], @@ -86,7 +88,7 @@ class WOStackUpgradeController(CementBaseController): wo_phpmyadmin = WODownload.pma_release(self) if not (pargs.web or pargs.nginx or pargs.php or pargs.php72 or pargs.php73 or pargs.php74 or - pargs.php80 or pargs.php81 or pargs.mysql or + pargs.php80 or pargs.php81 or pargs.php82 or pargs.mysql or pargs.mariadb or pargs.ngxblocker or pargs.all or pargs.netdata or pargs.wpcli or pargs.composer or pargs.phpmyadmin or pargs.adminer or pargs.dashboard or @@ -100,7 +102,7 @@ class WOStackUpgradeController(CementBaseController): pargs.mysql = True if pargs.php: - pargs.php72 = True + pargs.php81 = True if pargs.all: pargs.web = True @@ -115,6 +117,7 @@ class WOStackUpgradeController(CementBaseController): pargs.php74 = True pargs.php80 = True pargs.php81 = True + pargs.php82 = True pargs.mysql = True pargs.wpcli = True @@ -172,6 +175,12 @@ class WOStackUpgradeController(CementBaseController): apt_packages = apt_packages + WOVar.wo_php81 + \ WOVar.wo_php_extra + # php 8.2 + if pargs.php82: + if WOAptGet.is_installed(self, 'php8.2-fpm'): + apt_packages = apt_packages + WOVar.wo_php82 + \ + WOVar.wo_php_extra + # mysql if pargs.mysql: if WOShellExec.cmd_exec(self, 'mysqladmin ping'): @@ -301,6 +310,7 @@ class WOStackUpgradeController(CementBaseController): "php7.4-fpm" in apt_packages or "php8.0-fpm" in apt_packages or "php8.1-fpm" in apt_packages or + "php8.2-fpm" in apt_packages or "redis-server" in apt_packages or "nginx-custom" in apt_packages or "mariadb-server" in apt_packages): diff --git a/wo/cli/templates/upstream.mustache b/wo/cli/templates/upstream.mustache index 5b93f7e..715aeb4 100644 --- a/wo/cli/templates/upstream.mustache +++ b/wo/cli/templates/upstream.mustache @@ -125,6 +125,26 @@ upstream debug81 { server 127.0.0.1:9176; } +#------------------------------- +# PHP 8.2 +#------------------------------- + +# PHP 8.2 upstream with load-balancing on two unix sockets +upstream php82 { + least_conn; + + server unix:/var/run/php/php82-fpm.sock; + server unix:/var/run/php/php82-two-fpm.sock; + + keepalive 5; +} + +# PHP 8.2 debug +upstream debug82 { + # Debug Pool + server 127.0.0.1:9177; +} + #------------------------------- # Netdata #------------------------------- @@ -156,4 +176,5 @@ upstream multiphp { server unix:/var/run/php/php72-fpm.sock; server unix:/var/run/php/php80-fpm.sock; server unix:/var/run/php/php81-fpm.sock; -} \ No newline at end of file + server unix:/var/run/php/php82-fpm.sock; +} diff --git a/wo/core/services.py b/wo/core/services.py index 87811ba..9e49cfb 100644 --- a/wo/core/services.py +++ b/wo/core/services.py @@ -168,7 +168,9 @@ class WOService(): 'php7.3-fpm', 'php7.4-fpm', 'php8.0-fpm', - 'php8.1-fpm',]: + 'php8.1-fpm', + 'php8.2-fpm', + ]: retcode = subprocess.getstatusoutput('service {0} status' .format(service_name)) if retcode[0] == 0: diff --git a/wo/core/variables.py b/wo/core/variables.py index 4b426ec..54efe40 100644 --- a/wo/core/variables.py +++ b/wo/core/variables.py @@ -170,6 +170,9 @@ class WOVar(): wo_php81 = [] for module in wo_module: wo_php81 = wo_php81 + ["php8.1-{0}".format(module)] + wo_php82 = [] + for module in wo_module: + wo_php82 = wo_php82 + ["php8.2-{0}".format(module)] wo_php_extra = ["graphviz"]