Merge pull request #554 from WordOps/updating-configuration

Refactor php installation and site detection
This commit is contained in:
VirtuBox
2023-08-05 23:16:45 +02:00
committed by GitHub
6 changed files with 122 additions and 518 deletions

View File

@@ -9,6 +9,7 @@ from wo.core.aptget import WOAptGet
from wo.core.logging import Log
from wo.core.services import WOService
from wo.core.shellexec import WOShellExec
from wo.core.variables import WOVar
def wo_clean_hook(app):
@@ -54,7 +55,7 @@ class WOCleanController(CementBaseController):
@expose(hide=True)
def clean_redis(self):
"""This function clears Redis cache"""
if(WOAptGet.is_installed(self, "redis-server")):
if (WOAptGet.is_installed(self, "redis-server")):
Log.info(self, "Cleaning Redis cache")
WOShellExec.cmd_exec(self, "redis-cli flushall")
else:
@@ -62,7 +63,7 @@ class WOCleanController(CementBaseController):
@expose(hide=True)
def clean_fastcgi(self):
if(os.path.isdir("/var/run/nginx-cache") and
if (os.path.isdir("/var/run/nginx-cache") and
os.path.exists('/usr/sbin/nginx')):
Log.info(self, "Cleaning NGINX FastCGI cache")
WOShellExec.cmd_exec(self, "rm -rf /var/run/nginx-cache/*")
@@ -78,15 +79,12 @@ class WOCleanController(CementBaseController):
'/var/www/22222/htdocs/cache/opcache')):
try:
Log.info(self, "Cleaning opcache")
if os.path.exists('{0}php72.php'.format(opcache_dir)):
requests.get(
"http://127.0.0.1/cache/opcache/php72.php")
if os.path.exists('{0}php73.php'.format(opcache_dir)):
requests.get(
"http://127.0.0.1/cache/opcache/php73.php")
if os.path.exists('{0}php74.php'.format(opcache_dir)):
requests.get(
"http://127.0.0.1/cache/opcache/php74.php")
wo_php_version = list(WOVar.wo_php_versions.keys())
for wo_php in wo_php_version:
if os.path.exists('{0}{1}.php'.format(opcache_dir, wo_php)):
requests.get(
"http://127.0.0.1/cache/opcache/{0}.php".format(wo_php))
except requests.HTTPError as e:
Log.debug(self, "{0}".format(e))
Log.debug(self, "Unable hit url, "

View File

@@ -872,95 +872,34 @@ def site_package_check(self, stype):
wo_nginx.write('fastcgi_param \tSCRIPT_FILENAME '
'\t$request_filename;\n')
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.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.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")
php_versions = ['php72', 'php73', 'php74', 'php80', 'php81', 'php82']
selected_versions = [version for version in php_versions if getattr(pargs, version)]
if len(selected_versions) > 1:
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.php82) and
stype in ['php', 'mysql', 'wp', 'wpsubdir',
'wpsubdomain']):
Log.debug(self, "Setting apt_packages variable for PHP")
php_check = 'php8.0-fpm'
php_to_setup = WOVar.wo_php80
if self.app.config.has_section('php'):
config_php_ver = self.app.config.get(
'php', 'version')
if config_php_ver == '7.2':
php_check = 'php7.2-fpm'
php_to_setup = WOVar.wo_php72
elif config_php_ver == '7.3':
php_check = 'php7.3-fpm'
php_to_setup = WOVar.wo_php73
elif config_php_ver == '7.4':
php_check = 'php7.4-fpm'
php_to_setup = WOVar.wo_php74
elif config_php_ver == '8.0':
php_check = 'php8.0-fpm'
php_to_setup = WOVar.wo_php80
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.1-fpm'
php_to_setup = WOVar.wo_php81
else:
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
for version_key, version_number in WOVar.wo_php_versions.items():
if (self.app.config.has_section('php') and
self.app.config.get('php', 'version') == version_number):
Log.debug(
self,
f"Setting apt_packages variable for PHP {version_number}")
if not WOAptGet.is_installed(self, f'php{version_number}-fpm'):
apt_packages += getattr(
WOVar, f'wo_{version_key}') + WOVar.wo_php_extra
if pargs.php72 and stype in ['php72', 'mysql', 'wp',
'wpsubdir', 'wpsubdomain']:
Log.debug(self, "Setting apt_packages variable for PHP 7.2")
if not WOAptGet.is_installed(self, 'php7.2-fpm'):
apt_packages = apt_packages + WOVar.wo_php72 + WOVar.wo_php_extra
if pargs.php73 and stype in ['php73', 'mysql', 'wp',
'wpsubdir', 'wpsubdomain']:
Log.debug(self, "Setting apt_packages variable for PHP 7.3")
if not WOAptGet.is_installed(self, 'php7.3-fpm'):
apt_packages = apt_packages + WOVar.wo_php73 + WOVar.wo_php_extra
if pargs.php74 and stype in ['php74', 'mysql', 'wp',
'wpsubdir', 'wpsubdomain']:
Log.debug(self, "Setting apt_packages variable for PHP 7.4")
if not WOAptGet.is_installed(self, 'php7.4-fpm'):
apt_packages = apt_packages + WOVar.wo_php74 + WOVar.wo_php_extra
if pargs.php80 and stype in ['php80', 'mysql', 'wp',
'wpsubdir', 'wpsubdomain']:
Log.debug(self, "Setting apt_packages variable for PHP 8.0")
if not WOAptGet.is_installed(self, 'php8.0-fpm'):
apt_packages = apt_packages + WOVar.wo_php80 + WOVar.wo_php_extra
if pargs.php81 and stype in ['php81', 'mysql', 'wp',
'wpsubdir', 'wpsubdomain']:
Log.debug(self, "Setting apt_packages variable for PHP 8.1")
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
for version_key, version_number in WOVar.wo_php_versions.items():
if getattr(pargs, version_key) and stype in [version_key, 'mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
Log.debug(self, f"Setting apt_packages variable for PHP {version_number}")
if not WOAptGet.is_installed(self, f'php{version_number}-fpm'):
apt_packages += getattr(WOVar, f'wo_{version_key}') + WOVar.wo_php_extra
if stype in ['mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
Log.debug(self, "Setting apt_packages variable for MySQL")
@@ -1137,268 +1076,39 @@ def detSitePar(opts):
2. raises RuntimeError when wrong combination is used like
"--wp --wpsubdir" or "--html --wp"
"""
# Initialize sitetype and cachetype
sitetype, cachetype = '', ''
# Initialize type and cache lists
typelist = list()
cachelist = list()
# Populate type and cache lists based on opts
for key, val in opts.items():
if val and key in ['html', 'php', 'mysql', 'wp',
'wpsubdir', 'wpsubdomain', 'php72',
'php73', 'php74', 'php80', 'php81', 'php82', ]:
'wpsubdir', 'wpsubdomain',
'php72', 'php73', 'php74',
'php80', 'php81', 'php82']:
typelist.append(key)
elif val and key in ['wpfc', 'wpsc', 'wpredis', 'wprocket', 'wpce']:
cachelist.append(key)
# Determine sitetype and cachetype
if len(typelist) > 1 or len(cachelist) > 1:
if len(cachelist) > 1:
raise RuntimeError(
"Could not determine cache type."
"Multiple cache parameter entered")
elif False not in [x in ('php', 'mysql', 'html') for x in typelist]:
sitetype = 'mysql'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('php72', 'mysql', 'html') for x in typelist]:
sitetype = 'mysql'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('php73', 'mysql', 'html') for x in typelist]:
sitetype = 'mysql'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('php74', 'mysql', 'html') for x in typelist]:
sitetype = 'mysql'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('php80', 'mysql', 'html') for x in typelist]:
sitetype = 'mysql'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('php81', 'mysql', 'html') for x in typelist]:
sitetype = 'mysql'
if not cachelist:
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:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('php72', 'mysql') for x in typelist]:
sitetype = 'mysql'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('php73', 'mysql') for x in typelist]:
sitetype = 'mysql'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('php74', 'mysql') for x in typelist]:
sitetype = 'mysql'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('php80', 'mysql') for x in typelist]:
sitetype = 'mysql'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('php81', 'mysql') for x in typelist]:
sitetype = 'mysql'
if not cachelist:
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:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('php', 'html') for x in typelist]:
sitetype = 'php'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wp', 'wpsubdir') for x in typelist]:
sitetype = 'wpsubdir'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wp', 'wpsubdomain') for x in typelist]:
sitetype = 'wpsubdomain'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wp', 'php72') for x in typelist]:
sitetype = 'wp'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wp', 'php73') for x in typelist]:
sitetype = 'wp'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wp', 'php74') for x in typelist]:
sitetype = 'wp'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wp', 'php80') for x in typelist]:
sitetype = 'wp'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wp', 'php81') for x in typelist]:
sitetype = 'wp'
if not cachelist:
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:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wpsubdir', 'php73') for x in typelist]:
sitetype = 'wpsubdir'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wpsubdir', 'php74') for x in typelist]:
sitetype = 'wpsubdir'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wpsubdir', 'php80') for x in typelist]:
sitetype = 'wpsubdir'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wpsubdir', 'php81') for x in typelist]:
sitetype = 'wpsubdir'
if not cachelist:
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:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wpsubdomain', 'php73') for x in typelist]:
sitetype = 'wpsubdomain'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wpsubdomain', 'php74') for x in typelist]:
sitetype = 'wpsubdomain'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wpsubdomain', 'php80') for x in typelist]:
sitetype = 'wpsubdomain'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wpsubdomain', 'php81') for x in typelist]:
sitetype = 'wpsubdomain'
if not cachelist:
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")
raise RuntimeError(
"Could not determine site or cache type. "
"Multiple types or caches entered.")
# If no type or cache specified, set to None
if not typelist and not cachelist:
sitetype = None
cachetype = None
else:
if not typelist and not cachelist:
sitetype = None
cachetype = None
elif (not typelist or "php72" in typelist) and cachelist:
sitetype = 'wp'
cachetype = cachelist[0]
elif (not typelist or "php73" in typelist) and cachelist:
sitetype = 'wp'
cachetype = cachelist[0]
elif (not typelist or "php74" in typelist) and cachelist:
sitetype = 'wp'
cachetype = cachelist[0]
elif (not typelist or "php80" in typelist) and cachelist:
sitetype = 'wp'
cachetype = cachelist[0]
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'
else:
sitetype = typelist[0]
cachetype = cachelist[0]
# Use the first specified type or 'wp' if not specified
sitetype = typelist[0] if typelist else 'wp'
# Use the first specified cache or 'basic' if not specified
cachetype = cachelist[0] if cachelist else 'basic'
return (sitetype, cachetype)

View File

@@ -200,65 +200,23 @@ class WOStackController(CementBaseController):
else:
Log.debug(self, "Redis already installed")
# PHP 7.2
if pargs.php72:
Log.debug(self, "Setting apt_packages variable for PHP 7.2")
if not (WOAptGet.is_installed(self, 'php7.2-fpm')):
apt_packages = (apt_packages + WOVar.wo_php72 +
WOVar.wo_php_extra)
else:
Log.debug(self, "PHP 7.2 already installed")
Log.info(self, "PHP 7.2 already 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,
}
# PHP 7.3
if pargs.php73:
Log.debug(self, "Setting apt_packages variable for PHP 7.3")
if not WOAptGet.is_installed(self, 'php7.3-fpm'):
apt_packages = (apt_packages + WOVar.wo_php73 +
WOVar.wo_php_extra)
else:
Log.debug(self, "PHP 7.3 already installed")
Log.info(self, "PHP 7.3 already installed")
# PHP 7.4
if pargs.php74:
Log.debug(self, "Setting apt_packages variable for PHP 7.4")
if not WOAptGet.is_installed(self, 'php7.4-fpm'):
apt_packages = (apt_packages + WOVar.wo_php74 +
WOVar.wo_php_extra)
else:
Log.debug(self, "PHP 7.4 already installed")
Log.info(self, "PHP 7.4 already installed")
# PHP 8.0
if pargs.php80:
Log.debug(self, "Setting apt_packages variable for PHP 8.0")
if not WOAptGet.is_installed(self, 'php8.0-fpm'):
apt_packages = (apt_packages + WOVar.wo_php80 +
WOVar.wo_php_extra)
else:
Log.debug(self, "PHP 8.0 already installed")
Log.info(self, "PHP 8.0 already installed")
# PHP 8.1
if pargs.php81:
Log.debug(self, "Setting apt_packages variable for PHP 8.1")
if not WOAptGet.is_installed(self, 'php8.1-fpm'):
apt_packages = (apt_packages + WOVar.wo_php81 +
WOVar.wo_php_extra)
else:
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")
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] + WOVar.wo_php_extra
else:
Log.debug(self, f"PHP {version} already installed")
Log.info(self, f"PHP {version} already installed")
# MariaDB
if pargs.mysql:
@@ -669,97 +627,33 @@ class WOStackController(CementBaseController):
Log.debug(self, "Removing apt_packages variable of Nginx")
apt_packages = apt_packages + WOVar.wo_nginx
# 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
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') 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")
Log.info(self, "PHP 7.2 is not installed")
# Create a dictionary that maps PHP versions to corresponding variables.
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,
}
# 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
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') 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")
Log.info(self, "PHP 7.3 is not installed")
# Loop through all versions.
for parg_version, version in WOVar.wo_php_versions.items():
# Check if this version is present in pargs.
if getattr(pargs, parg_version):
Log.debug(self, f"Setting apt_packages variable for PHP {version}")
# 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
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') 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")
Log.info(self, "PHP 7.4 is not installed")
if WOAptGet.is_installed(self, f'php{version}-fpm'):
apt_packages += wo_vars[parg_version]
# 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
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') 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")
Log.info(self, "PHP 8.0 is not installed")
# Check if other versions are installed.
if not any(WOAptGet.is_installed(self, f'php{other_version}-fpm') for
other_version in WOVar.wo_php_versions.values() if other_version != version):
apt_packages += WOVar.wo_php_extra
# 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
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.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")
else:
Log.debug(self, f"PHP {version} is not installed")
Log.info(self, f"PHP {version} is not installed")
# REDIS
if pargs.redis:

View File

@@ -12,7 +12,7 @@ class WOConf():
def nginxcommon(self):
"""nginx common configuration deployment"""
wo_php_version = ["php72", "php73", "php74", "php80", "php81", "php82"]
wo_php_version = list(WOVar.wo_php_versions.keys())
ngxcom = '/etc/nginx/common'
if not os.path.exists(ngxcom):
os.mkdir(ngxcom)

View File

@@ -150,31 +150,35 @@ class WOVar():
wo_nginx = ["nginx-custom", "nginx-wo"]
wo_nginx_key = 'FB898660'
wo_module = ["bcmath", "cli", "common", "curl", "fpm", "gd", "igbinary",
"imagick", "imap", "intl", "mbstring", "memcached", "msgpack",
"mysql", "opcache", "readline", "redis", "soap", "xdebug",
"xml", "zip"]
wo_php72 = []
for module in wo_module:
wo_php72 = wo_php72 + ["php7.2-{0}".format(module)]
wo_php72 = wo_php72 + ["php7.2-recode"]
wo_php73 = []
for module in wo_module:
wo_php73 = wo_php73 + ["php7.3-{0}".format(module)]
wo_php73 = wo_php73 + ["php7.3-recode"]
wo_php74 = []
for module in wo_module:
wo_php74 = wo_php74 + ["php7.4-{0}".format(module)]
wo_php74 = wo_php74 + ["php7.4-geoip", "php7.4-json"]
wo_php80 = []
for module in wo_module:
wo_php80 = wo_php80 + ["php8.0-{0}".format(module)]
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_versions = {
'php72': '7.2',
'php73': '7.3',
'php74': '7.4',
'php80': '8.0',
'php81': '8.1',
'php82': '8.2',
}
def generate_php_modules(version_prefix, version_number):
wo_module = ["bcmath", "cli", "common", "curl", "fpm", "gd", "igbinary",
"imagick", "imap", "intl", "mbstring", "memcached", "msgpack",
"mysql", "opcache", "readline", "redis", "soap", "xdebug",
"xml", "zip"]
php_modules = ["php{0}-{1}".format(version_number, module) for module in wo_module]
if version_prefix == 'php72' or version_prefix == 'php73':
php_modules.append("php{0}-recode".format(version_number))
elif version_prefix == 'php74':
php_modules.extend(["php{0}-geoip".format(version_number), "php{0}-json".format(version_number)])
return php_modules
wo_php72 = generate_php_modules('php72', '7.2')
wo_php73 = generate_php_modules('php73', '7.3')
wo_php74 = generate_php_modules('php74', '7.4')
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_php_extra = ["graphviz"]
@@ -182,10 +186,7 @@ class WOVar():
"mariadb-server", "percona-toolkit",
"mariadb-common", "python3-mysqldb"]
if wo_distro == 'raspbian':
if wo_platform_codename == 'stretch':
mariadb_ver = '10.1'
else:
mariadb_ver = '10.3'
mariadb_ver = '10.3'
else:
mariadb_ver = '10.11'
wo_mysql = wo_mysql + ["mariadb-backup"]