Refactor php installation
This commit is contained in:
@@ -466,25 +466,46 @@ def post_pref(self, apt_packages, packages, upgrade=False):
|
||||
WOShellExec.cmd_exec(self, 'systemctl daemon-reload')
|
||||
WOService.restart_service(self, 'nginx')
|
||||
|
||||
# php conf
|
||||
php_list = []
|
||||
if 'php7.2-fpm' in apt_packages:
|
||||
php_list = php_list + [["7.2"]]
|
||||
if 'php7.3-fpm' in apt_packages:
|
||||
php_list = php_list + [["7.3"]]
|
||||
if 'php7.4-fpm' in apt_packages:
|
||||
php_list = php_list + [["7.4"]]
|
||||
if 'php8.0-fpm' in apt_packages:
|
||||
php_list = php_list + [["8.0"]]
|
||||
if 'php8.1-fpm' in apt_packages:
|
||||
php_list = php_list + [["8.1"]]
|
||||
if 'php8.2-fpm' in apt_packages:
|
||||
php_list = php_list + [["8.2"]]
|
||||
|
||||
for php_version in php_list:
|
||||
WOGit.add(self, ["/etc/php"], msg="Adding PHP into Git")
|
||||
Log.info(self, "Configuring php7.2-fpm")
|
||||
Log.info(self, "Configuring php{0}-fpm".format(php_version))
|
||||
ngxroot = '/var/www/'
|
||||
|
||||
# Create log directories
|
||||
if not os.path.exists('/var/log/php/7.2/'):
|
||||
Log.debug(self, 'Creating directory /var/log/php/7.2/')
|
||||
os.makedirs('/var/log/php/7.2/')
|
||||
if not os.path.exists('/var/log/php/{0}/'.format(php_version)):
|
||||
Log.debug(
|
||||
self, 'Creating directory /var/log/php/{0}/'
|
||||
.format(php_version))
|
||||
os.makedirs('/var/log/php/{0}/'.format(php_version))
|
||||
|
||||
if not os.path.isfile('/etc/php/7.2/fpm/php.ini.orig'):
|
||||
WOFileUtils.copyfile(self, '/etc/php/7.2/fpm/php.ini',
|
||||
'/etc/php/7.2/fpm/php.ini.orig')
|
||||
if not os.path.isfile(
|
||||
'/etc/php/{0}/fpm/php.ini.orig'.format(php_version)):
|
||||
WOFileUtils.copyfile(self,
|
||||
'/etc/php/{0}/fpm/php.ini'.format(
|
||||
php_version),
|
||||
'/etc/php/{0}/fpm/php.ini.orig'
|
||||
.format(php_version))
|
||||
|
||||
# Parse etc/php/7.2/fpm/php.ini
|
||||
# Parse etc/php/x.x/fpm/php.ini
|
||||
config = configparser.ConfigParser()
|
||||
Log.debug(self, "configuring php file "
|
||||
"/etc/php/7.2/fpm/php.ini")
|
||||
config.read('/etc/php/7.2/fpm/php.ini.orig')
|
||||
"/etc/php/{0}/fpm/php.ini".format(php_version))
|
||||
config.read('/etc/php/{0}/fpm/php.ini.orig'.format(php_version))
|
||||
config['PHP']['expose_php'] = 'Off'
|
||||
config['PHP']['post_max_size'] = '100M'
|
||||
config['PHP']['upload_max_filesize'] = '100M'
|
||||
@@ -500,51 +521,68 @@ def post_pref(self, apt_packages, packages, upgrade=False):
|
||||
config['opcache']['opcache.revalidate_freq'] = '5'
|
||||
config['opcache']['opcache.consistency_checks'] = '0'
|
||||
config['opcache']['opcache.validate_timestamps'] = '1'
|
||||
with open('/etc/php/7.2/fpm/php.ini',
|
||||
with open('/etc/php/{0}/fpm/php.ini'.format(php_version),
|
||||
encoding='utf-8', mode='w') as configfile:
|
||||
Log.debug(self, "Writting php configuration into "
|
||||
"/etc/php/7.2/fpm/php.ini")
|
||||
"/etc/php/{0}/fpm/php.ini".format(php_version))
|
||||
config.write(configfile)
|
||||
|
||||
# Render php-fpm pool template for php7.3
|
||||
data = dict(pid="/run/php/php7.2-fpm.pid",
|
||||
error_log="/var/log/php7.2-fpm.log",
|
||||
include="/etc/php/7.2/fpm/pool.d/*.conf")
|
||||
# Render php-fpm pool template for phpx.x
|
||||
data = dict(pid="/run/php/php{0}-fpm.pid".format(php_version),
|
||||
error_log="/var/log/php{0}-fpm.log".format(
|
||||
php_version),
|
||||
include="/etc/php/{0}/fpm/pool.d/*.conf"
|
||||
.format(php_version))
|
||||
WOTemplate.deploy(
|
||||
self, '/etc/php/7.2/fpm/php-fpm.conf',
|
||||
self, '/etc/php/{0}/fpm/php-fpm.conf'.format(php_version),
|
||||
'php-fpm.mustache', data)
|
||||
|
||||
data = dict(pool='www-php72', listen='php72-fpm.sock',
|
||||
php_short = php_version.replace(".", "")
|
||||
data = dict(pool='www-php{0}'.format(php_short),
|
||||
listen='php{0}-fpm.sock'.format(php_short),
|
||||
user='www-data',
|
||||
group='www-data', listenuser='root',
|
||||
listengroup='www-data', openbasedir=True)
|
||||
WOTemplate.deploy(self, '/etc/php/7.2/fpm/pool.d/www.conf',
|
||||
WOTemplate.deploy(self, '/etc/php/{0}/fpm/pool.d/www.conf'
|
||||
.format(php_version),
|
||||
'php-pool.mustache', data)
|
||||
data = dict(pool='www-two-php72', listen='php72-two-fpm.sock',
|
||||
data = dict(pool='www-two-php{0}'.format(php_short),
|
||||
listen='php{0}-two-fpm.sock'.format(php_short),
|
||||
user='www-data',
|
||||
group='www-data', listenuser='root',
|
||||
listengroup='www-data', openbasedir=True)
|
||||
WOTemplate.deploy(self, '/etc/php/7.2/fpm/pool.d/www-two.conf',
|
||||
WOTemplate.deploy(self,
|
||||
'/etc/php/{0}/fpm/pool.d/www-two.conf'.format(
|
||||
php_version),
|
||||
'php-pool.mustache', data)
|
||||
|
||||
# Generate /etc/php/7.2/fpm/pool.d/debug.conf
|
||||
WOFileUtils.copyfile(self, "/etc/php/7.2/fpm/pool.d/www.conf",
|
||||
"/etc/php/7.2/fpm/pool.d/debug.conf")
|
||||
WOFileUtils.searchreplace(self, "/etc/php/7.2/fpm/pool.d/"
|
||||
"debug.conf", "[www-php72]", "[debug]")
|
||||
# Generate /etc/php/x.x/fpm/pool.d/debug.conf
|
||||
WOFileUtils.copyfile(self,
|
||||
"/etc/php/{0}/fpm/pool.d/www.conf".format(
|
||||
php_version),
|
||||
"/etc/php/{0}/fpm/pool.d/debug.conf"
|
||||
.format(php_version))
|
||||
WOFileUtils.searchreplace(self,
|
||||
"/etc/php/{0}/fpm/pool.d/"
|
||||
"debug.conf".format(php_version),
|
||||
"[www-php{0}]".format(php_short),
|
||||
"[debug]")
|
||||
config = configparser.ConfigParser()
|
||||
config.read('/etc/php/7.2/fpm/pool.d/debug.conf')
|
||||
config['debug']['listen'] = '127.0.0.1:9172'
|
||||
config.read(
|
||||
'/etc/php/{0}/fpm/pool.d/debug.conf'.format(php_version))
|
||||
config['debug']['listen'] = '127.0.0.1:91{0}'.format(php_short)
|
||||
config['debug']['rlimit_core'] = 'unlimited'
|
||||
config['debug']['slowlog'] = '/var/log/php/7.2/slow.log'
|
||||
config['debug']['slowlog'] = '/var/log/php/{0}/slow.log'.format(
|
||||
php_version)
|
||||
config['debug']['request_slowlog_timeout'] = '10s'
|
||||
with open('/etc/php/7.2/fpm/pool.d/debug.conf',
|
||||
with open('/etc/php/{0}/fpm/pool.d/debug.conf'.format(php_version),
|
||||
encoding='utf-8', mode='w') as confifile:
|
||||
Log.debug(self, "writting PHP7.2 configuration into "
|
||||
"/etc/php/7.2/fpm/pool.d/debug.conf")
|
||||
Log.debug(self,
|
||||
"writting PHP configuration into "
|
||||
"/etc/php/{0}/fpm/pool.d/debug.conf"
|
||||
.format(php_version))
|
||||
config.write(confifile)
|
||||
|
||||
with open("/etc/php/7.2/fpm/pool.d/debug.conf",
|
||||
with open("/etc/php/{0}/fpm/pool.d/debug.conf".format(php_version),
|
||||
encoding='utf-8', mode='a') as myfile:
|
||||
myfile.write("php_admin_value[xdebug.profiler_output_dir] "
|
||||
"= /tmp/ \nphp_admin_value[xdebug.profiler_"
|
||||
@@ -555,11 +593,11 @@ def post_pref(self, apt_packages, packages, upgrade=False):
|
||||
|
||||
# Disable xdebug
|
||||
if not WOShellExec.cmd_exec(self, "grep -q \';zend_extension\'"
|
||||
" /etc/php/7.2/mods-available/"
|
||||
"xdebug.ini"):
|
||||
WOFileUtils.searchreplace(self, "/etc/php/7.2/"
|
||||
" /etc/php/{0}/mods-available/"
|
||||
"xdebug.ini".format(php_version)):
|
||||
WOFileUtils.searchreplace(self, "/etc/php/{0}/"
|
||||
"mods-available/"
|
||||
"xdebug.ini",
|
||||
"xdebug.ini".format(php_version),
|
||||
"zend_extension",
|
||||
";zend_extension")
|
||||
|
||||
@@ -571,11 +609,11 @@ def post_pref(self, apt_packages, packages, upgrade=False):
|
||||
.format(ngxroot))
|
||||
os.makedirs('{0}22222/htdocs/fpm/status/'
|
||||
.format(ngxroot))
|
||||
open('{0}22222/htdocs/fpm/status/debug72'
|
||||
.format(ngxroot),
|
||||
open('{0}22222/htdocs/fpm/status/debug{1}'
|
||||
.format(ngxroot, php_short),
|
||||
encoding='utf-8', mode='a').close()
|
||||
open('{0}22222/htdocs/fpm/status/php72'
|
||||
.format(ngxroot),
|
||||
open('{0}22222/htdocs/fpm/status/php{1}'
|
||||
.format(ngxroot, php_short),
|
||||
encoding='utf-8', mode='a').close()
|
||||
|
||||
# Write info.php
|
||||
@@ -592,14 +630,14 @@ def post_pref(self, apt_packages, packages, upgrade=False):
|
||||
encoding='utf-8', mode='w') as myfile:
|
||||
myfile.write("<?php\nphpinfo();\n?>")
|
||||
|
||||
# write opcache clean for php72
|
||||
# write opcache clean for phpxx
|
||||
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/php72.php'
|
||||
.format(ngxroot),
|
||||
self, '{0}22222/htdocs/cache/opcache/php{1}.php'
|
||||
.format(ngxroot, php_short),
|
||||
'<?php opcache_reset(); ?>')
|
||||
|
||||
WOFileUtils.chown(self, "{0}22222/htdocs"
|
||||
@@ -611,800 +649,16 @@ def post_pref(self, apt_packages, packages, upgrade=False):
|
||||
WOShellExec.cmd_exec(self, 'phpenmod -v ALL imagick')
|
||||
|
||||
# check service restart or rollback configuration
|
||||
if not WOService.restart_service(self, 'php7.2-fpm'):
|
||||
WOGit.rollback(self, ["/etc/php"], msg="Rollback PHP")
|
||||
else:
|
||||
WOGit.add(self, ["/etc/php"], msg="Adding PHP into Git")
|
||||
|
||||
# PHP7.3 configuration
|
||||
if set(WOVar.wo_php73).issubset(set(apt_packages)):
|
||||
WOGit.add(self, ["/etc/php"], msg="Adding PHP into Git")
|
||||
Log.info(self, "Configuring php7.3-fpm")
|
||||
ngxroot = '/var/www/'
|
||||
# Create log directories
|
||||
if not os.path.exists('/var/log/php/7.3/'):
|
||||
Log.debug(self, 'Creating directory /var/log/php/7.3/')
|
||||
os.makedirs('/var/log/php/7.3/')
|
||||
|
||||
if not os.path.isfile('/etc/php/7.3/fpm/php.ini.orig'):
|
||||
WOFileUtils.copyfile(self, '/etc/php/7.3/fpm/php.ini',
|
||||
'/etc/php/7.3/fpm/php.ini.orig')
|
||||
|
||||
# Parse etc/php/7.3/fpm/php.ini
|
||||
config = configparser.ConfigParser()
|
||||
Log.debug(self, "configuring php file /etc/php/7.3/"
|
||||
"fpm/php.ini")
|
||||
config.read('/etc/php/7.3/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'
|
||||
with open('/etc/php/7.3/fpm/php.ini',
|
||||
encoding='utf-8', mode='w') as configfile:
|
||||
Log.debug(self, "Writting php configuration into "
|
||||
"/etc/php/7.3/fpm/php.ini")
|
||||
config.write(configfile)
|
||||
|
||||
# Render php-fpm pool template for php7.3
|
||||
data = dict(pid="/run/php/php7.3-fpm.pid",
|
||||
error_log="/var/log/php7.3-fpm.log",
|
||||
include="/etc/php/7.3/fpm/pool.d/*.conf")
|
||||
WOTemplate.deploy(
|
||||
self, '/etc/php/7.3/fpm/php-fpm.conf',
|
||||
'php-fpm.mustache', data)
|
||||
|
||||
data = dict(pool='www-php73', listen='php73-fpm.sock',
|
||||
user='www-data',
|
||||
group='www-data', listenuser='root',
|
||||
listengroup='www-data', openbasedir=True)
|
||||
WOTemplate.deploy(self, '/etc/php/7.3/fpm/pool.d/www.conf',
|
||||
'php-pool.mustache', data)
|
||||
data = dict(pool='www-two-php73', listen='php73-two-fpm.sock',
|
||||
user='www-data',
|
||||
group='www-data', listenuser='root',
|
||||
listengroup='www-data', openbasedir=True)
|
||||
WOTemplate.deploy(self, '/etc/php/7.3/fpm/pool.d/www-two.conf',
|
||||
'php-pool.mustache', data)
|
||||
|
||||
# Generate /etc/php/7.3/fpm/pool.d/debug.conf
|
||||
WOFileUtils.copyfile(self, "/etc/php/7.3/fpm/pool.d/www.conf",
|
||||
"/etc/php/7.3/fpm/pool.d/debug.conf")
|
||||
WOFileUtils.searchreplace(self, "/etc/php/7.3/fpm/pool.d/"
|
||||
"debug.conf", "[www-php73]", "[debug]")
|
||||
config = configparser.ConfigParser()
|
||||
config.read('/etc/php/7.3/fpm/pool.d/debug.conf')
|
||||
config['debug']['listen'] = '127.0.0.1:9173'
|
||||
config['debug']['rlimit_core'] = 'unlimited'
|
||||
config['debug']['slowlog'] = '/var/log/php/7.3/slow.log'
|
||||
config['debug']['request_slowlog_timeout'] = '10s'
|
||||
with open('/etc/php/7.3/fpm/pool.d/debug.conf',
|
||||
encoding='utf-8', mode='w') as confifile:
|
||||
Log.debug(self, "writting PHP 7.3 configuration into "
|
||||
"/etc/php/7.3/fpm/pool.d/debug.conf")
|
||||
config.write(confifile)
|
||||
|
||||
with open("/etc/php/7.3/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/7.3/mods-available/xdebug.ini"):
|
||||
WOFileUtils.searchreplace(
|
||||
self, "/etc/php/7.3/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/debug73'
|
||||
.format(ngxroot),
|
||||
encoding='utf-8', mode='a').close()
|
||||
open('{0}22222/htdocs/fpm/status/php73'
|
||||
.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))
|
||||
|
||||
with open("{0}22222/htdocs/php/info.php"
|
||||
.format(ngxroot),
|
||||
encoding='utf-8', mode='w') as myfile:
|
||||
myfile.write("<?php\nphpinfo();\n?>")
|
||||
|
||||
# write opcache clean for php73
|
||||
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/php73.php'
|
||||
.format(ngxroot),
|
||||
'<?php opcache_reset(); ?>')
|
||||
|
||||
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, 'php7.3-fpm'):
|
||||
WOGit.rollback(self, ["/etc/php"], msg="Rollback PHP")
|
||||
else:
|
||||
WOGit.add(self, ["/etc/php"], msg="Adding PHP into Git")
|
||||
|
||||
# PHP7.4 configuration
|
||||
# php7.4 configuration
|
||||
if set(WOVar.wo_php74).issubset(set(apt_packages)):
|
||||
WOGit.add(self, ["/etc/php"], msg="Adding PHP into Git")
|
||||
Log.info(self, "Configuring php7.4-fpm")
|
||||
ngxroot = '/var/www/'
|
||||
# Create log directories
|
||||
if not os.path.exists('/var/log/php/7.4/'):
|
||||
Log.debug(self, 'Creating directory /var/log/php/7.4/')
|
||||
os.makedirs('/var/log/php/7.4/')
|
||||
|
||||
if not os.path.isfile('/etc/php/7.4/fpm/php.ini.orig'):
|
||||
WOFileUtils.copyfile(self, '/etc/php/7.4/fpm/php.ini',
|
||||
'/etc/php/7.4/fpm/php.ini.orig')
|
||||
|
||||
# Parse etc/php/7.4/fpm/php.ini
|
||||
config = configparser.ConfigParser()
|
||||
Log.debug(self, "configuring php file /etc/php/7.4/"
|
||||
"fpm/php.ini")
|
||||
config.read('/etc/php/7.4/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/7.4/fpm/php.ini',
|
||||
encoding='utf-8', mode='w') as configfile:
|
||||
Log.debug(self, "Writting php configuration into "
|
||||
"/etc/php/7.4/fpm/php.ini")
|
||||
config.write(configfile)
|
||||
|
||||
# Render php-fpm pool template for php7.4
|
||||
data = dict(pid="/run/php/php7.4-fpm.pid",
|
||||
error_log="/var/log/php7.4-fpm.log",
|
||||
include="/etc/php/7.4/fpm/pool.d/*.conf")
|
||||
WOTemplate.deploy(
|
||||
self, '/etc/php/7.4/fpm/php-fpm.conf',
|
||||
'php-fpm.mustache', data)
|
||||
|
||||
data = dict(pool='www-php74', listen='php74-fpm.sock',
|
||||
user='www-data',
|
||||
group='www-data', listenuser='root',
|
||||
listengroup='www-data', openbasedir=True)
|
||||
WOTemplate.deploy(self, '/etc/php/7.4/fpm/pool.d/www.conf',
|
||||
'php-pool.mustache', data)
|
||||
data = dict(pool='www-two-php74', listen='php74-two-fpm.sock',
|
||||
user='www-data',
|
||||
group='www-data', listenuser='root',
|
||||
listengroup='www-data', openbasedir=True)
|
||||
WOTemplate.deploy(self, '/etc/php/7.4/fpm/pool.d/www-two.conf',
|
||||
'php-pool.mustache', data)
|
||||
|
||||
# Generate /etc/php/7.4/fpm/pool.d/debug.conf
|
||||
WOFileUtils.copyfile(self, "/etc/php/7.4/fpm/pool.d/www.conf",
|
||||
"/etc/php/7.4/fpm/pool.d/debug.conf")
|
||||
WOFileUtils.searchreplace(self, "/etc/php/7.4/fpm/pool.d/"
|
||||
"debug.conf", "[www-php74]", "[debug]")
|
||||
config = configparser.ConfigParser()
|
||||
config.read('/etc/php/7.4/fpm/pool.d/debug.conf')
|
||||
config['debug']['listen'] = '127.0.0.1:9174'
|
||||
config['debug']['rlimit_core'] = 'unlimited'
|
||||
config['debug']['slowlog'] = '/var/log/php/7.4/slow.log'
|
||||
config['debug']['request_slowlog_timeout'] = '10s'
|
||||
with open('/etc/php/7.4/fpm/pool.d/debug.conf',
|
||||
encoding='utf-8', mode='w') as confifile:
|
||||
Log.debug(self, "writting PHP 7.4 configuration into "
|
||||
"/etc/php/7.4/fpm/pool.d/debug.conf")
|
||||
config.write(confifile)
|
||||
|
||||
with open("/etc/php/7.4/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/7.4/mods-available/xdebug.ini"):
|
||||
WOFileUtils.searchreplace(
|
||||
self, "/etc/php/7.4/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/debug74'
|
||||
.format(ngxroot),
|
||||
encoding='utf-8', mode='a').close()
|
||||
open('{0}22222/htdocs/fpm/status/php74'
|
||||
.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), "<?php\nphpinfo();\n?>")
|
||||
|
||||
# write opcache clean for php74
|
||||
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/php74.php'
|
||||
.format(ngxroot),
|
||||
'<?php opcache_reset(); ?>')
|
||||
|
||||
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, 'php7.4-fpm'):
|
||||
if not WOService.restart_service(self,
|
||||
'php{0}-fpm'.format(php_version)):
|
||||
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', 'php74'):
|
||||
data = dict(php="9000", debug="9001",
|
||||
php7="9070", debug7="9170",
|
||||
release=WOVar.wo_version)
|
||||
WOTemplate.deploy(
|
||||
self, '/etc/nginx/conf.d/upstream.conf',
|
||||
'upstream.mustache', data, True)
|
||||
WOConf.nginxcommon(self)
|
||||
|
||||
# php8.0 configuration
|
||||
if set(WOVar.wo_php80).issubset(set(apt_packages)):
|
||||
WOGit.add(self, ["/etc/php"], msg="Adding PHP into Git")
|
||||
Log.info(self, "Configuring php8.0-fpm")
|
||||
ngxroot = '/var/www/'
|
||||
# Create log directories
|
||||
if not os.path.exists('/var/log/php/8.0/'):
|
||||
Log.debug(self, 'Creating directory /var/log/php/8.0/')
|
||||
os.makedirs('/var/log/php/8.0/')
|
||||
|
||||
if not os.path.isfile('/etc/php/8.0/fpm/php.ini.orig'):
|
||||
WOFileUtils.copyfile(self, '/etc/php/8.0/fpm/php.ini',
|
||||
'/etc/php/8.0/fpm/php.ini.orig')
|
||||
|
||||
# Parse etc/php/8.0/fpm/php.ini
|
||||
config = configparser.ConfigParser()
|
||||
Log.debug(self, "configuring php file /etc/php/8.0/"
|
||||
"fpm/php.ini")
|
||||
config.read('/etc/php/8.0/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.0/fpm/php.ini',
|
||||
encoding='utf-8', mode='w') as configfile:
|
||||
Log.debug(self, "Writting php configuration into "
|
||||
"/etc/php/8.0/fpm/php.ini")
|
||||
config.write(configfile)
|
||||
|
||||
# Render php-fpm pool template for php8.0
|
||||
data = dict(pid="/run/php/php8.0-fpm.pid",
|
||||
error_log="/var/log/php8.0-fpm.log",
|
||||
include="/etc/php/8.0/fpm/pool.d/*.conf")
|
||||
WOTemplate.deploy(
|
||||
self, '/etc/php/8.0/fpm/php-fpm.conf',
|
||||
'php-fpm.mustache', data)
|
||||
|
||||
data = dict(pool='www-php80', listen='php80-fpm.sock',
|
||||
user='www-data',
|
||||
group='www-data', listenuser='root',
|
||||
listengroup='www-data', openbasedir=True)
|
||||
WOTemplate.deploy(self, '/etc/php/8.0/fpm/pool.d/www.conf',
|
||||
'php-pool.mustache', data)
|
||||
data = dict(pool='www-two-php80', listen='php80-two-fpm.sock',
|
||||
user='www-data',
|
||||
group='www-data', listenuser='root',
|
||||
listengroup='www-data', openbasedir=True)
|
||||
WOTemplate.deploy(self, '/etc/php/8.0/fpm/pool.d/www-two.conf',
|
||||
'php-pool.mustache', data)
|
||||
|
||||
# Generate /etc/php/8.0/fpm/pool.d/debug.conf
|
||||
WOFileUtils.copyfile(self, "/etc/php/8.0/fpm/pool.d/www.conf",
|
||||
"/etc/php/8.0/fpm/pool.d/debug.conf")
|
||||
WOFileUtils.searchreplace(self, "/etc/php/8.0/fpm/pool.d/"
|
||||
"debug.conf", "[www-php80]", "[debug]")
|
||||
config = configparser.ConfigParser()
|
||||
config.read('/etc/php/8.0/fpm/pool.d/debug.conf')
|
||||
config['debug']['listen'] = '127.0.0.1:9180'
|
||||
config['debug']['rlimit_core'] = 'unlimited'
|
||||
config['debug']['slowlog'] = '/var/log/php/8.0/slow.log'
|
||||
config['debug']['request_slowlog_timeout'] = '10s'
|
||||
with open('/etc/php/8.0/fpm/pool.d/debug.conf',
|
||||
encoding='utf-8', mode='w') as confifile:
|
||||
Log.debug(self, "writting PHP 8.0 configuration into "
|
||||
"/etc/php/8.0/fpm/pool.d/debug.conf")
|
||||
config.write(confifile)
|
||||
|
||||
with open("/etc/php/8.0/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.0/mods-available/xdebug.ini"):
|
||||
WOFileUtils.searchreplace(
|
||||
self, "/etc/php/8.0/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/debug80'
|
||||
.format(ngxroot),
|
||||
encoding='utf-8', mode='a').close()
|
||||
open('{0}22222/htdocs/fpm/status/php80'
|
||||
.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), "<?php\nphpinfo();\n?>")
|
||||
|
||||
# write opcache clean for php80
|
||||
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/php80.php'
|
||||
.format(ngxroot),
|
||||
'<?php opcache_reset(); ?>')
|
||||
|
||||
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.0-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', 'php80'):
|
||||
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)
|
||||
|
||||
# php8.1 configuration
|
||||
if set(WOVar.wo_php81).issubset(set(apt_packages)):
|
||||
WOGit.add(self, ["/etc/php"], msg="Adding PHP into Git")
|
||||
Log.info(self, "Configuring php8.1-fpm")
|
||||
ngxroot = '/var/www/'
|
||||
# Create log directories
|
||||
if not os.path.exists('/var/log/php/8.1/'):
|
||||
Log.debug(self, 'Creating directory /var/log/php/8.1/')
|
||||
os.makedirs('/var/log/php/8.1/')
|
||||
|
||||
if not os.path.isfile('/etc/php/8.1/fpm/php.ini.orig'):
|
||||
WOFileUtils.copyfile(self, '/etc/php/8.1/fpm/php.ini',
|
||||
'/etc/php/8.1/fpm/php.ini.orig')
|
||||
|
||||
# Parse etc/php/8.1/fpm/php.ini
|
||||
config = configparser.ConfigParser()
|
||||
Log.debug(self, "configuring php file /etc/php/8.1/"
|
||||
"fpm/php.ini")
|
||||
config.read('/etc/php/8.1/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.1/fpm/php.ini',
|
||||
encoding='utf-8', mode='w') as configfile:
|
||||
Log.debug(self, "Writting php configuration into "
|
||||
"/etc/php/8.1/fpm/php.ini")
|
||||
config.write(configfile)
|
||||
|
||||
# Render php-fpm pool template for php8.1
|
||||
data = dict(pid="/run/php/php8.1-fpm.pid",
|
||||
error_log="/var/log/php8.1-fpm.log",
|
||||
include="/etc/php/8.1/fpm/pool.d/*.conf")
|
||||
WOTemplate.deploy(
|
||||
self, '/etc/php/8.1/fpm/php-fpm.conf',
|
||||
'php-fpm.mustache', data)
|
||||
|
||||
data = dict(pool='www-php81', listen='php81-fpm.sock',
|
||||
user='www-data',
|
||||
group='www-data', listenuser='root',
|
||||
listengroup='www-data', openbasedir=True)
|
||||
WOTemplate.deploy(self, '/etc/php/8.1/fpm/pool.d/www.conf',
|
||||
'php-pool.mustache', data)
|
||||
data = dict(pool='www-two-php81', listen='php81-two-fpm.sock',
|
||||
user='www-data',
|
||||
group='www-data', listenuser='root',
|
||||
listengroup='www-data', openbasedir=True)
|
||||
WOTemplate.deploy(self, '/etc/php/8.1/fpm/pool.d/www-two.conf',
|
||||
'php-pool.mustache', data)
|
||||
|
||||
# Generate /etc/php/8.1/fpm/pool.d/debug.conf
|
||||
WOFileUtils.copyfile(self, "/etc/php/8.1/fpm/pool.d/www.conf",
|
||||
"/etc/php/8.1/fpm/pool.d/debug.conf")
|
||||
WOFileUtils.searchreplace(self, "/etc/php/8.1/fpm/pool.d/"
|
||||
"debug.conf", "[www-php81]", "[debug]")
|
||||
config = configparser.ConfigParser()
|
||||
config.read('/etc/php/8.1/fpm/pool.d/debug.conf')
|
||||
config['debug']['listen'] = '127.0.0.1:9181'
|
||||
config['debug']['rlimit_core'] = 'unlimited'
|
||||
config['debug']['slowlog'] = '/var/log/php/8.1/slow.log'
|
||||
config['debug']['request_slowlog_timeout'] = '10s'
|
||||
with open('/etc/php/8.1/fpm/pool.d/debug.conf',
|
||||
encoding='utf-8', mode='w') as confifile:
|
||||
Log.debug(self, "writting PHP 8.1 configuration into "
|
||||
"/etc/php/8.1/fpm/pool.d/debug.conf")
|
||||
config.write(confifile)
|
||||
|
||||
with open("/etc/php/8.1/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.1/mods-available/xdebug.ini"):
|
||||
WOFileUtils.searchreplace(
|
||||
self, "/etc/php/8.1/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/debug81'
|
||||
.format(ngxroot),
|
||||
encoding='utf-8', mode='a').close()
|
||||
open('{0}22222/htdocs/fpm/status/php81'
|
||||
.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), "<?php\nphpinfo();\n?>")
|
||||
|
||||
# write opcache clean for php81
|
||||
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/php81.php'
|
||||
.format(ngxroot),
|
||||
'<?php opcache_reset(); ?>')
|
||||
|
||||
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.1-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', 'php81'):
|
||||
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)
|
||||
|
||||
# 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), "<?php\nphpinfo();\n?>")
|
||||
|
||||
# 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),
|
||||
'<?php opcache_reset(); ?>')
|
||||
|
||||
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'):
|
||||
'php{0}'.format(php_short)):
|
||||
data = dict(php="9000", debug="9001",
|
||||
php7="9070", debug7="9170",
|
||||
php8="9080", debug8="9180",
|
||||
|
||||
Reference in New Issue
Block a user