From f699012b9b778e68559f35fcf3ef759aeda2cee8 Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Thu, 23 Nov 2023 21:33:09 +0100 Subject: [PATCH] Add php8.3 support --- wo/cli/plugins/info.py | 4 +- wo/cli/plugins/site_create.py | 2 +- wo/cli/plugins/site_functions.py | 42 ++++++++++++++-- wo/cli/plugins/site_update.py | 23 ++++----- wo/cli/plugins/stack.py | 78 +++++++++--------------------- wo/cli/plugins/stack_upgrade.py | 2 + wo/cli/templates/upstream.mustache | 21 ++++++++ wo/core/variables.py | 2 + 8 files changed, 101 insertions(+), 73 deletions(-) diff --git a/wo/cli/plugins/info.py b/wo/cli/plugins/info.py index 705e9f3..626c255 100644 --- a/wo/cli/plugins/info.py +++ b/wo/cli/plugins/info.py @@ -629,7 +629,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 and not pargs.php82): + not pargs.php81 and not pargs.php82) and not (pargs.php83): pargs.nginx = True pargs.php = True pargs.mysql = True @@ -643,6 +643,8 @@ class WOInfoController(CementBaseController): pargs.php81 = True if WOAptGet.is_installed(self, 'php8.2-fpm'): pargs.php82 = True + if WOAptGet.is_installed(self, 'php8.3-fpm'): + pargs.php83 = True if pargs.nginx: if ((not WOAptGet.is_installed(self, 'nginx-custom')) and diff --git a/wo/cli/plugins/site_create.py b/wo/cli/plugins/site_create.py index 91e5388..71ac773 100644 --- a/wo/cli/plugins/site_create.py +++ b/wo/cli/plugins/site_create.py @@ -186,7 +186,7 @@ class WOSiteCreateController(CementBaseController): data['basic'] = True if (pargs.php72 or pargs.php73 or pargs.php74 or - pargs.php80 or pargs.php81 or pargs.php82): + pargs.php80 or pargs.php81 or pargs.php82 or pargs.php83): data = dict( site_name=wo_domain, www_domain=wo_www_domain, static=False, basic=False, diff --git a/wo/cli/plugins/site_functions.py b/wo/cli/plugins/site_functions.py index 7af1f50..ecb18d7 100644 --- a/wo/cli/plugins/site_functions.py +++ b/wo/cli/plugins/site_functions.py @@ -775,7 +775,7 @@ def sitebackup(self, data): .format(data['site_name']), backup_path) if data['currsitetype'] in ['html', 'php', 'php72', 'php74', - 'php73', 'php80', 'php81', 'php82', + 'php73', 'php80', 'php81', 'php82', 'php83' 'proxy', 'mysql']: if not data['wp']: Log.info(self, "Backing up Webroot \t\t", end='') @@ -836,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', 'php82', 'alias']: + 'wpsubdomain', 'php73', 'php74', 'php80', 'php81', 'php82', 'php83', 'alias']: Log.debug(self, "Setting apt_packages variable for Nginx") # Check if server has nginx-custom package @@ -872,7 +872,7 @@ def site_package_check(self, stype): wo_nginx.write('fastcgi_param \tSCRIPT_FILENAME ' '\t$request_filename;\n') - php_versions = ['php72', 'php73', 'php74', 'php80', 'php81', 'php82'] + php_versions = ['php72', 'php73', 'php74', 'php80', 'php81', 'php82', 'php83'] selected_versions = [version for version in php_versions if getattr(pargs, version)] if len(selected_versions) > 1: @@ -881,6 +881,7 @@ def site_package_check(self, stype): if ((not pargs.php72) and (not pargs.php73) and (not pargs.php74) and (not pargs.php80) and (not pargs.php81) and (not pargs.php82) and + (not pargs.php83) and stype in ['php', 'mysql', 'wp', 'wpsubdir', 'wpsubdomain']): Log.debug(self, "Setting apt_packages variable for PHP") @@ -1082,7 +1083,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', 'php82', ]: + 'php73', 'php74', 'php80', 'php81', 'php82', 'php83']: typelist.append(key) elif val and key in ['wpfc', 'wpsc', 'wpredis', 'wprocket', 'wpce']: cachelist.append(key) @@ -1134,6 +1135,12 @@ def detSitePar(opts): cachetype = 'basic' else: cachetype = cachelist[0] + elif False not in [x in ('php83', '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: @@ -1176,6 +1183,12 @@ def detSitePar(opts): cachetype = 'basic' else: cachetype = cachelist[0] + elif False not in [x in ('php83', '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: @@ -1236,6 +1249,12 @@ def detSitePar(opts): cachetype = 'basic' else: cachetype = cachelist[0] + elif False not in [x in ('wp', 'php83') 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: @@ -1272,6 +1291,12 @@ def detSitePar(opts): cachetype = 'basic' else: cachetype = cachelist[0] + elif False not in [x in ('wpsubdir', 'php83') 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: @@ -1308,6 +1333,12 @@ def detSitePar(opts): cachetype = 'basic' else: cachetype = cachelist[0] + elif False not in [x in ('wpsubdomain', 'php83') 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: @@ -1332,6 +1363,9 @@ def detSitePar(opts): elif (not typelist or "php82" in typelist) and cachelist: sitetype = 'wp' cachetype = cachelist[0] + elif (not typelist or "php83" 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/site_update.py b/wo/cli/plugins/site_update.py index 319d044..adc8035 100644 --- a/wo/cli/plugins/site_update.py +++ b/wo/cli/plugins/site_update.py @@ -188,7 +188,7 @@ class WOSiteUpdateController(CementBaseController): pargs.ngxblocker or pargs.letsencrypt == 'renew') and not ( pargs.html 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.wp or pargs.wpfc or pargs.wpsc or + pargs.php83 or pargs.mysql or pargs.wp or pargs.wpfc or pargs.wpsc or pargs.wprocket or pargs.wpce or pargs.wpsubdir or pargs.wpsubdomain)): @@ -256,20 +256,20 @@ class WOSiteUpdateController(CementBaseController): if (((stype == 'php' and oldsitetype not in ['html', 'proxy', 'php', 'php72', 'php73', 'php74', 'php80', - 'php81', 'php82']) or + 'php81', 'php82', 'php83']) or (stype == 'mysql' and oldsitetype not in [ 'html', 'php', 'php72', 'php73', 'php74', 'php80', 'php81', - 'php82', 'proxy']) or + 'php82', 'php83', 'proxy']) or (stype == 'wp' and oldsitetype not in [ 'html', 'php', 'php72', 'php73', 'php74', 'php80', 'php81', - 'php82', 'mysql', 'proxy', 'wp']) or + 'php82', 'php83', 'mysql', 'proxy', 'wp']) or (stype == 'wpsubdir' and oldsitetype in ['wpsubdomain']) or (stype == 'wpsubdomain' and oldsitetype in ['wpsubdir']) or (stype == oldsitetype and cache == oldcachetype)) and not (pargs.php72 or pargs.php73 or pargs.php74 or pargs.php80 or pargs.php81 or pargs.php82 or - pargs.alias)): + pargs.php83 or pargs.alias)): Log.info(self, Log.FAIL + "can not update {0} {1} to {2} {3}". format(oldsitetype, oldcachetype, stype, cache)) return 1 @@ -298,7 +298,7 @@ class WOSiteUpdateController(CementBaseController): site_name=wo_domain, www_domain=wo_www_domain, static=False, basic=True, wp=False, wpfc=False, php72=False, php73=False, php74=False, - php80=False, php81=False, php82=False, + php80=False, php81=False, php82=False, php83=False, wpsc=False, wpredis=False, wprocket=False, wpce=False, multisite=False, wpsubdir=False, webroot=wo_site_webroot, currsitetype=oldsitetype, currcachetype=oldcachetype) @@ -323,11 +323,11 @@ class WOSiteUpdateController(CementBaseController): data['wpsubdir'] = True if ((pargs.php72 or pargs.php73 or pargs.php74 or - pargs.php80 or pargs.php81 or pargs.php82) and + pargs.php80 or pargs.php81 or pargs.php82 or pargs.php83) and (not data)): Log.debug( self, "pargs php72, or php73, or php74, " - "or php80, or php81 or php82 enabled") + "or php80, or php81 or php82 or php83 enabled") data = dict( site_name=wo_domain, www_domain=wo_www_domain, @@ -344,7 +344,7 @@ class WOSiteUpdateController(CementBaseController): elif (oldsitetype == 'php' or oldsitetype == 'mysql' or oldsitetype == 'php73' or oldsitetype == 'php74' or oldsitetype == 'php80' or oldsitetype == 'php81' or - oldsitetype == 'php82'): + oldsitetype == 'php82' or oldsitetype == 'php83'): data['static'] = False data['wp'] = False data['multisite'] = False @@ -396,7 +396,8 @@ class WOSiteUpdateController(CementBaseController): if (data and (not pargs.php73) and (not pargs.php74) and (not pargs.php72) and - (not pargs.php80) and (not pargs.php81) and (not pargs.php82)): + (not pargs.php80) and (not pargs.php81) and (not pargs.php82) + and (not pargs.php83)): data[pargs_version] = bool(old_version_var is True) Log.debug( self, f"data {pargs_version} = {data[pargs_version]}") @@ -798,7 +799,7 @@ class WOSiteUpdateController(CementBaseController): # Setup WordPress if old sites are html/php/mysql sites if data['wp'] and oldsitetype in ['html', 'proxy', 'php', 'php72', 'mysql', 'php73', 'php74', 'php80', - 'php81', 'php82']: + 'php81', 'php82', 'php83']: try: wo_wp_creds = setupwordpress(self, data) except SiteError as e: diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index 0373ae3..8204e42 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -130,6 +130,7 @@ class WOStackController(CementBaseController): pargs.php80 = True pargs.php81 = True pargs.php82 = True + pargs.php83 = True pargs.redis = True pargs.proftpd = True @@ -188,6 +189,7 @@ class WOStackController(CementBaseController): 'php80': WOVar.wo_php80, 'php81': WOVar.wo_php81, 'php82': WOVar.wo_php82, + 'php83': WOVar.wo_php83, } for parg_version, version in WOVar.wo_php_versions.items(): @@ -554,6 +556,7 @@ class WOStackController(CementBaseController): pargs.php80 = True pargs.php81 = True pargs.php82 = True + pargs.php83 = True pargs.fail2ban = True pargs.proftpd = True pargs.utils = True @@ -596,6 +599,7 @@ class WOStackController(CementBaseController): 'php80': WOVar.wo_php80, 'php81': WOVar.wo_php81, 'php82': WOVar.wo_php82, + 'php83': WOVar.wo_php83, } # Loop through all versions. @@ -856,6 +860,7 @@ class WOStackController(CementBaseController): pargs.php80 = True pargs.php81 = True pargs.php82 = True + pargs.php83 = True pargs.fail2ban = True pargs.proftpd = True pargs.utils = True @@ -891,63 +896,24 @@ class WOStackController(CementBaseController): else: Log.info(self, "Nginx is not installed") - # PHP 7.2 - if pargs.php72: - Log.debug(self, "Setting apt_packages variable for PHP 7.2") - if (WOAptGet.is_installed(self, 'php7.2-fpm')): - apt_packages = apt_packages + WOVar.wo_php72 - else: - Log.debug(self, "PHP 7.2 is not installed") - Log.info(self, "PHP 7.2 is not installed") + wo_vars = { + 'php72': WOVar.wo_php72, + 'php73': WOVar.wo_php73, + 'php74': WOVar.wo_php74, + 'php80': WOVar.wo_php80, + 'php81': WOVar.wo_php81, + 'php82': WOVar.wo_php82, + 'php83': WOVar.wo_php83, + } - # PHP 7.3 - if pargs.php73: - Log.debug(self, "Setting apt_packages variable for PHP 7.3") - if WOAptGet.is_installed(self, 'php7.3-fpm'): - apt_packages = apt_packages + WOVar.wo_php73 - else: - Log.debug(self, "PHP 7.3 is not installed") - Log.info(self, "PHP 7.3 is not installed") - - # PHP 7.4 - if pargs.php74: - Log.debug(self, "Setting apt_packages variable for PHP 7.4") - if WOAptGet.is_installed(self, 'php7.4-fpm'): - apt_packages = apt_packages + WOVar.wo_php74 - else: - Log.debug(self, "PHP 7.4 is not installed") - Log.info(self, "PHP 7.4 is not installed") - - # PHP 8.0 - if pargs.php80: - Log.debug(self, "Setting apt_packages variable for PHP 8.0") - if WOAptGet.is_installed(self, 'php8.0-fpm'): - apt_packages = apt_packages + WOVar.wo_php80 - else: - Log.debug(self, "PHP 8.0 is not installed") - Log.info(self, "PHP 8.0 is not installed") - - # PHP 8.1 - if pargs.php81: - Log.debug(self, "Setting apt_packages variable for PHP 8.1") - if WOAptGet.is_installed(self, 'php8.1-fpm'): - apt_packages = apt_packages + WOVar.wo_php81 - 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_php82 - 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") + for parg_version, version in WOVar.wo_php_versions.items(): + if getattr(pargs, parg_version, False): + Log.debug(self, f"Setting apt_packages variable for PHP {version}") + if not WOAptGet.is_installed(self, f'php{version}-fpm'): + apt_packages = apt_packages + wo_vars[parg_version] + else: + Log.debug(self, f"PHP {version} already purged") + Log.info(self, f"PHP {version} already purged") # REDIS if pargs.redis: diff --git a/wo/cli/plugins/stack_upgrade.py b/wo/cli/plugins/stack_upgrade.py index ce71af0..0dcd65e 100644 --- a/wo/cli/plugins/stack_upgrade.py +++ b/wo/cli/plugins/stack_upgrade.py @@ -107,6 +107,7 @@ class WOStackUpgradeController(CementBaseController): pargs.php80 = True pargs.php81 = True pargs.php82 = True + pargs.php83 = True pargs.mysql = True pargs.wpcli = True @@ -141,6 +142,7 @@ class WOStackUpgradeController(CementBaseController): 'php80': WOVar.wo_php80, 'php81': WOVar.wo_php81, 'php82': WOVar.wo_php82, + 'php83': WOVar.wo_php83, } for parg_version, version in WOVar.wo_php_versions.items(): diff --git a/wo/cli/templates/upstream.mustache b/wo/cli/templates/upstream.mustache index 715aeb4..fa5cd8b 100644 --- a/wo/cli/templates/upstream.mustache +++ b/wo/cli/templates/upstream.mustache @@ -145,6 +145,26 @@ upstream debug82 { server 127.0.0.1:9177; } +#------------------------------- +# PHP 8.3 +#------------------------------- + +# PHP 8.3 upstream with load-balancing on two unix sockets +upstream php83 { + least_conn; + + server unix:/var/run/php/php83-fpm.sock; + server unix:/var/run/php/php83-two-fpm.sock; + + keepalive 5; +} + +# PHP 8.3 debug +upstream debug83 { + # Debug Pool + server 127.0.0.1:9178; +} + #------------------------------- # Netdata #------------------------------- @@ -177,4 +197,5 @@ upstream multiphp { server unix:/var/run/php/php80-fpm.sock; server unix:/var/run/php/php81-fpm.sock; server unix:/var/run/php/php82-fpm.sock; + server unix:/var/run/php/php83-fpm.sock; } diff --git a/wo/core/variables.py b/wo/core/variables.py index f8953fa..8b17819 100644 --- a/wo/core/variables.py +++ b/wo/core/variables.py @@ -157,6 +157,7 @@ class WOVar(): 'php80': '8.0', 'php81': '8.1', 'php82': '8.2', + 'php83': '8.3', } def generate_php_modules(version_prefix, version_number): @@ -179,6 +180,7 @@ class WOVar(): wo_php80 = generate_php_modules('php80', '8.0') wo_php81 = generate_php_modules('php81', '8.1') wo_php82 = generate_php_modules('php82', '8.2') + wo_php83 = generate_php_modules('php83', '8.3') wo_php_extra = ["graphviz"]