Fix php upgrade

This commit is contained in:
VirtuBox
2019-08-05 12:25:00 +02:00
parent e84fed489e
commit 915b3f41f8
2 changed files with 288 additions and 287 deletions

View File

@@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
#### Changed #### Changed
- Moving package configuration in a new plugin stack_pref.py - Moving package configuration in a new plugin stack_pref.py
- Set WordOps backend password length from 16 to 24
### v3.9.7 - 2019-08-02 ### v3.9.7 - 2019-08-02

View File

@@ -412,16 +412,16 @@ def post_pref(self, apt_packages, packages):
out=wo_nginx) out=wo_nginx)
wo_nginx.close() wo_nginx.close()
passwd = ''.join([random.choice randompass = ''.join([random.choice
(string.ascii_letters + string.digits) (string.ascii_letters + string.digits)
for n in range(16)]) for n in range(24)])
try: try:
WOShellExec.cmd_exec(self, "printf \"WordOps:" WOShellExec.cmd_exec(self, "printf \"WordOps:"
"$(openssl passwd -crypt " "$(openssl passwd -crypt "
"{password} 2> /dev/null)\n\"" "{password} 2> /dev/null)\n\""
"> /etc/nginx/htpasswd-wo " "> /etc/nginx/htpasswd-wo "
"2>/dev/null" "2>/dev/null"
.format(password=passwd)) .format(password=randompass))
except CommandExecutionError as e: except CommandExecutionError as e:
Log.debug(self, "{0}".format(e)) Log.debug(self, "{0}".format(e))
Log.error(self, "Failed to save HTTP Auth") Log.error(self, "Failed to save HTTP Auth")
@@ -589,161 +589,161 @@ def post_pref(self, apt_packages, packages):
os.makedirs('/var/log/php/7.2/') os.makedirs('/var/log/php/7.2/')
# Parse etc/php/7.2/fpm/php.ini # Parse etc/php/7.2/fpm/php.ini
config = configparser.ConfigParser() config = configparser.ConfigParser()
Log.debug(self, "configuring php file " Log.debug(self, "configuring php file "
"/etc/php/7.2/fpm/php.ini")
config.read('/etc/php/7.2/fpm/php.ini')
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'] = WOVariables.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.2/fpm/php.ini',
encoding='utf-8', mode='w') as configfile:
Log.debug(self, "Writting php configuration into "
"/etc/php/7.2/fpm/php.ini") "/etc/php/7.2/fpm/php.ini")
config.read('/etc/php/7.2/fpm/php.ini') config.write(configfile)
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'] = WOVariables.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.2/fpm/php.ini',
encoding='utf-8', mode='w') as configfile:
Log.debug(self, "Writting php configuration into "
"/etc/php/7.2/fpm/php.ini")
config.write(configfile)
# Parse /etc/php/7.2/fpm/php-fpm.conf # Parse /etc/php/7.2/fpm/php-fpm.conf
data = dict(pid="/run/php/php7.2-fpm.pid", data = dict(pid="/run/php/php7.2-fpm.pid",
error_log="/var/log/php/7.2/fpm.log", error_log="/var/log/php/7.2/fpm.log",
include="/etc/php/7.2/fpm/pool.d/*.conf") include="/etc/php/7.2/fpm/pool.d/*.conf")
Log.debug(self, "writting php7.2 configuration into " Log.debug(self, "writting php7.2 configuration into "
"/etc/php/7.2/fpm/php-fpm.conf") "/etc/php/7.2/fpm/php-fpm.conf")
wo_php_fpm = open('/etc/php/7.2/fpm/php-fpm.conf', wo_php_fpm = open('/etc/php/7.2/fpm/php-fpm.conf',
encoding='utf-8', mode='w') encoding='utf-8', mode='w')
self.app.render((data), 'php-fpm.mustache', out=wo_php_fpm) self.app.render((data), 'php-fpm.mustache', out=wo_php_fpm)
wo_php_fpm.close() wo_php_fpm.close()
# Parse /etc/php/7.2/fpm/pool.d/www.conf # Parse /etc/php/7.2/fpm/pool.d/www.conf
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read_file(codecs.open('/etc/php/7.2/fpm/' config.read_file(codecs.open('/etc/php/7.2/fpm/'
'pool.d/www.conf', 'pool.d/www.conf',
"r", "utf8")) "r", "utf8"))
config['www']['ping.path'] = '/ping' config['www']['ping.path'] = '/ping'
config['www']['pm.status_path'] = '/status' config['www']['pm.status_path'] = '/status'
config['www']['pm.max_requests'] = '1500' config['www']['pm.max_requests'] = '1500'
config['www']['pm.max_children'] = '50' config['www']['pm.max_children'] = '50'
config['www']['pm.start_servers'] = '10' config['www']['pm.start_servers'] = '10'
config['www']['pm.min_spare_servers'] = '5' config['www']['pm.min_spare_servers'] = '5'
config['www']['pm.max_spare_servers'] = '15' config['www']['pm.max_spare_servers'] = '15'
config['www']['request_terminate_timeout'] = '300' config['www']['request_terminate_timeout'] = '300'
config['www']['pm'] = 'ondemand' config['www']['pm'] = 'ondemand'
config['www']['chdir'] = '/' config['www']['chdir'] = '/'
config['www']['prefix'] = '/var/run/php' config['www']['prefix'] = '/var/run/php'
config['www']['listen'] = 'php72-fpm.sock' config['www']['listen'] = 'php72-fpm.sock'
config['www']['listen.mode'] = '0660' config['www']['listen.mode'] = '0660'
config['www']['listen.backlog'] = '32768' config['www']['listen.backlog'] = '32768'
config['www']['catch_workers_output'] = 'yes' config['www']['catch_workers_output'] = 'yes'
with codecs.open('/etc/php/7.2/fpm/pool.d/www.conf', with codecs.open('/etc/php/7.2/fpm/pool.d/www.conf',
encoding='utf-8', mode='w') as configfile: encoding='utf-8', mode='w') as configfile:
Log.debug(self, "Writing PHP 7.2 configuration into " Log.debug(self, "Writing PHP 7.2 configuration into "
"/etc/php/7.2/fpm/pool.d/www.conf") "/etc/php/7.2/fpm/pool.d/www.conf")
config.write(configfile) config.write(configfile)
with open("/etc/php/7.2/fpm/pool.d/www.conf", with open("/etc/php/7.2/fpm/pool.d/www.conf",
encoding='utf-8', mode='a') as myfile: encoding='utf-8', mode='a') as myfile:
myfile.write("\nphp_admin_value[open_basedir] " myfile.write("\nphp_admin_value[open_basedir] "
"= \"/var/www/:/usr/share/php/:" "= \"/var/www/:/usr/share/php/:"
"/tmp/:/var/run/nginx-cache/:" "/tmp/:/var/run/nginx-cache/:"
"/dev/shm:/dev/urandom\"\n") "/dev/shm:/dev/urandom\"\n")
# Generate /etc/php/7.2/fpm/pool.d/www-two.conf # Generate /etc/php/7.2/fpm/pool.d/www-two.conf
WOFileUtils.copyfile(self, "/etc/php/7.2/fpm/pool.d/www.conf", WOFileUtils.copyfile(self, "/etc/php/7.2/fpm/pool.d/www.conf",
"/etc/php/7.2/fpm/pool.d/www-two.conf") "/etc/php/7.2/fpm/pool.d/www-two.conf")
WOFileUtils.searchreplace(self, "/etc/php/7.2/fpm/pool.d/" WOFileUtils.searchreplace(self, "/etc/php/7.2/fpm/pool.d/"
"www-two.conf", "[www]", "[www-two]") "www-two.conf", "[www]", "[www-two]")
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read('/etc/php/7.2/fpm/pool.d/www-two.conf') config.read('/etc/php/7.2/fpm/pool.d/www-two.conf')
config['www-two']['listen'] = 'php72-two-fpm.sock' config['www-two']['listen'] = 'php72-two-fpm.sock'
with open('/etc/php/7.2/fpm/pool.d/www-two.conf', with open('/etc/php/7.2/fpm/pool.d/www-two.conf',
encoding='utf-8', mode='w') as confifile: encoding='utf-8', mode='w') as confifile:
Log.debug(self, "writting PHP7.2 configuration into " Log.debug(self, "writting PHP7.2 configuration into "
"/etc/php/7.2/fpm/pool.d/www-two.conf") "/etc/php/7.2/fpm/pool.d/www-two.conf")
config.write(confifile) config.write(confifile)
# Generate /etc/php/7.2/fpm/pool.d/debug.conf # Generate /etc/php/7.2/fpm/pool.d/debug.conf
WOFileUtils.copyfile(self, "/etc/php/7.2/fpm/pool.d/www.conf", WOFileUtils.copyfile(self, "/etc/php/7.2/fpm/pool.d/www.conf",
"/etc/php/7.2/fpm/pool.d/debug.conf") "/etc/php/7.2/fpm/pool.d/debug.conf")
WOFileUtils.searchreplace(self, "/etc/php/7.2/fpm/pool.d/" WOFileUtils.searchreplace(self, "/etc/php/7.2/fpm/pool.d/"
"debug.conf", "[www]", "[debug]") "debug.conf", "[www]", "[debug]")
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read('/etc/php/7.2/fpm/pool.d/debug.conf') config.read('/etc/php/7.2/fpm/pool.d/debug.conf')
config['debug']['listen'] = '127.0.0.1:9172' config['debug']['listen'] = '127.0.0.1:9172'
config['debug']['rlimit_core'] = 'unlimited' config['debug']['rlimit_core'] = 'unlimited'
config['debug']['slowlog'] = '/var/log/php/7.2/slow.log' config['debug']['slowlog'] = '/var/log/php/7.2/slow.log'
config['debug']['request_slowlog_timeout'] = '10s' config['debug']['request_slowlog_timeout'] = '10s'
with open('/etc/php/7.2/fpm/pool.d/debug.conf', with open('/etc/php/7.2/fpm/pool.d/debug.conf',
encoding='utf-8', mode='w') as confifile: encoding='utf-8', mode='w') as confifile:
Log.debug(self, "writting PHP7.2 configuration into " Log.debug(self, "writting PHP7.2 configuration into "
"/etc/php/7.2/fpm/pool.d/debug.conf") "/etc/php/7.2/fpm/pool.d/debug.conf")
config.write(confifile) config.write(confifile)
with open("/etc/php/7.2/fpm/pool.d/debug.conf", with open("/etc/php/7.2/fpm/pool.d/debug.conf",
encoding='utf-8', mode='a') as myfile: encoding='utf-8', mode='a') as myfile:
myfile.write("php_admin_value[xdebug.profiler_output_dir] " myfile.write("php_admin_value[xdebug.profiler_output_dir] "
"= /tmp/ \nphp_admin_value[xdebug.profiler_" "= /tmp/ \nphp_admin_value[xdebug.profiler_"
"output_name] = cachegrind.out.%p-%H-%R " "output_name] = cachegrind.out.%p-%H-%R "
"\nphp_admin_flag[xdebug.profiler_enable" "\nphp_admin_flag[xdebug.profiler_enable"
"_trigger] = on \nphp_admin_flag[xdebug." "_trigger] = on \nphp_admin_flag[xdebug."
"profiler_enable] = off\n") "profiler_enable] = off\n")
# Disable xdebug # Disable xdebug
if not WOShellExec.cmd_exec(self, "grep -q \';zend_extension\'" if not WOShellExec.cmd_exec(self, "grep -q \';zend_extension\'"
" /etc/php/7.2/mods-available/" " /etc/php/7.2/mods-available/"
"xdebug.ini"): "xdebug.ini"):
WOFileUtils.searchreplace(self, "/etc/php/7.2/" WOFileUtils.searchreplace(self, "/etc/php/7.2/"
"mods-available/" "mods-available/"
"xdebug.ini", "xdebug.ini",
"zend_extension", "zend_extension",
";zend_extension") ";zend_extension")
# PHP and Debug pull configuration # PHP and Debug pull configuration
if not os.path.exists('{0}22222/htdocs/fpm/status/' if not os.path.exists('{0}22222/htdocs/fpm/status/'
.format(WOVariables.wo_webroot)): .format(WOVariables.wo_webroot)):
Log.debug(self, 'Creating directory ' Log.debug(self, 'Creating directory '
'{0}22222/htdocs/fpm/status/ ' '{0}22222/htdocs/fpm/status/ '
.format(WOVariables.wo_webroot)) .format(WOVariables.wo_webroot))
os.makedirs('{0}22222/htdocs/fpm/status/' os.makedirs('{0}22222/htdocs/fpm/status/'
.format(WOVariables.wo_webroot)) .format(WOVariables.wo_webroot))
open('{0}22222/htdocs/fpm/status/debug72' open('{0}22222/htdocs/fpm/status/debug72'
.format(WOVariables.wo_webroot), .format(WOVariables.wo_webroot),
encoding='utf-8', mode='a').close() encoding='utf-8', mode='a').close()
open('{0}22222/htdocs/fpm/status/php72' open('{0}22222/htdocs/fpm/status/php72'
.format(WOVariables.wo_webroot), .format(WOVariables.wo_webroot),
encoding='utf-8', mode='a').close() encoding='utf-8', mode='a').close()
# Write info.php # Write info.php
if not os.path.exists('{0}22222/htdocs/php/' if not os.path.exists('{0}22222/htdocs/php/'
.format(WOVariables.wo_webroot)): .format(WOVariables.wo_webroot)):
Log.debug(self, 'Creating directory ' Log.debug(self, 'Creating directory '
'{0}22222/htdocs/php/ ' '{0}22222/htdocs/php/ '
.format(WOVariables.wo_webroot)) .format(WOVariables.wo_webroot))
os.makedirs('{0}22222/htdocs/php' os.makedirs('{0}22222/htdocs/php'
.format(WOVariables.wo_webroot)) .format(WOVariables.wo_webroot))
with open("{0}22222/htdocs/php/info.php" with open("{0}22222/htdocs/php/info.php"
.format(WOVariables.wo_webroot), .format(WOVariables.wo_webroot),
encoding='utf-8', mode='w') as myfile: encoding='utf-8', mode='w') as myfile:
myfile.write("<?php\nphpinfo();\n?>") myfile.write("<?php\nphpinfo();\n?>")
WOFileUtils.chown(self, "{0}22222" WOFileUtils.chown(self, "{0}22222"
.format(WOVariables.wo_webroot), .format(WOVariables.wo_webroot),
WOVariables.wo_php_user, WOVariables.wo_php_user,
WOVariables.wo_php_user, recursive=True) WOVariables.wo_php_user, recursive=True)
WOGit.add(self, ["/etc/php"], msg="Adding PHP into Git") WOGit.add(self, ["/etc/php"], msg="Adding PHP into Git")
WOService.restart_service(self, 'php7.2-fpm') WOService.restart_service(self, 'php7.2-fpm')
# PHP7.3 configuration # PHP7.3 configuration
if set(WOVariables.wo_php73).issubset(set(apt_packages)): if set(WOVariables.wo_php73).issubset(set(apt_packages)):
@@ -752,162 +752,162 @@ def post_pref(self, apt_packages, packages):
Log.debug(self, 'Creating directory /var/log/php/7.3/') Log.debug(self, 'Creating directory /var/log/php/7.3/')
os.makedirs('/var/log/php/7.3/') os.makedirs('/var/log/php/7.3/')
# Parse etc/php/7.3/fpm/php.ini # Parse etc/php/7.3/fpm/php.ini
config = configparser.ConfigParser() config = configparser.ConfigParser()
Log.debug(self, "configuring php file /etc/php/7.3/" Log.debug(self, "configuring php file /etc/php/7.3/"
"fpm/php.ini") "fpm/php.ini")
config.read('/etc/php/7.3/fpm/php.ini') config.read('/etc/php/7.3/fpm/php.ini')
config['PHP']['expose_php'] = 'Off' config['PHP']['expose_php'] = 'Off'
config['PHP']['post_max_size'] = '100M' config['PHP']['post_max_size'] = '100M'
config['PHP']['upload_max_filesize'] = '100M' config['PHP']['upload_max_filesize'] = '100M'
config['PHP']['max_execution_time'] = '300' config['PHP']['max_execution_time'] = '300'
config['PHP']['max_input_time'] = '300' config['PHP']['max_input_time'] = '300'
config['PHP']['max_input_vars'] = '20000' config['PHP']['max_input_vars'] = '20000'
config['Date']['date.timezone'] = WOVariables.wo_timezone config['Date']['date.timezone'] = WOVariables.wo_timezone
config['opcache']['opcache.enable'] = '1' config['opcache']['opcache.enable'] = '1'
config['opcache']['opcache.interned_strings_buffer'] = '8' config['opcache']['opcache.interned_strings_buffer'] = '8'
config['opcache']['opcache.max_accelerated_files'] = '10000' config['opcache']['opcache.max_accelerated_files'] = '10000'
config['opcache']['opcache.memory_consumption'] = '256' config['opcache']['opcache.memory_consumption'] = '256'
config['opcache']['opcache.save_comments'] = '1' config['opcache']['opcache.save_comments'] = '1'
config['opcache']['opcache.revalidate_freq'] = '5' config['opcache']['opcache.revalidate_freq'] = '5'
config['opcache']['opcache.consistency_checks'] = '0' config['opcache']['opcache.consistency_checks'] = '0'
config['opcache']['opcache.validate_timestamps'] = '1' config['opcache']['opcache.validate_timestamps'] = '1'
with open('/etc/php/7.3/fpm/php.ini', with open('/etc/php/7.3/fpm/php.ini',
encoding='utf-8', mode='w') as configfile: encoding='utf-8', mode='w') as configfile:
Log.debug(self, "Writting php configuration into " Log.debug(self, "Writting php configuration into "
"/etc/php/7.3/fpm/php.ini") "/etc/php/7.3/fpm/php.ini")
config.write(configfile) config.write(configfile)
# Parse /etc/php/7.3/fpm/php-fpm.conf # Parse /etc/php/7.3/fpm/php-fpm.conf
data = dict(pid="/run/php/php7.3-fpm.pid", data = dict(pid="/run/php/php7.3-fpm.pid",
error_log="/var/log/php7.3-fpm.log", error_log="/var/log/php7.3-fpm.log",
include="/etc/php/7.3/fpm/pool.d/*.conf") include="/etc/php/7.3/fpm/pool.d/*.conf")
Log.debug(self, "writting php 7.3 configuration into " Log.debug(self, "writting php 7.3 configuration into "
"/etc/php/7.3/fpm/php-fpm.conf") "/etc/php/7.3/fpm/php-fpm.conf")
wo_php_fpm = open('/etc/php/7.3/fpm/php-fpm.conf', wo_php_fpm = open('/etc/php/7.3/fpm/php-fpm.conf',
encoding='utf-8', mode='w') encoding='utf-8', mode='w')
self.app.render((data), 'php-fpm.mustache', out=wo_php_fpm) self.app.render((data), 'php-fpm.mustache', out=wo_php_fpm)
wo_php_fpm.close() wo_php_fpm.close()
# Parse /etc/php/7.3/fpm/pool.d/www.conf # Parse /etc/php/7.3/fpm/pool.d/www.conf
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read_file(codecs.open('/etc/php/7.3/fpm/' config.read_file(codecs.open('/etc/php/7.3/fpm/'
'pool.d/www.conf', 'pool.d/www.conf',
"r", "utf8")) "r", "utf8"))
config['www']['ping.path'] = '/ping' config['www']['ping.path'] = '/ping'
config['www']['pm.status_path'] = '/status' config['www']['pm.status_path'] = '/status'
config['www']['pm.max_requests'] = '1500' config['www']['pm.max_requests'] = '1500'
config['www']['pm.max_children'] = '50' config['www']['pm.max_children'] = '50'
config['www']['pm.start_servers'] = '10' config['www']['pm.start_servers'] = '10'
config['www']['pm.min_spare_servers'] = '5' config['www']['pm.min_spare_servers'] = '5'
config['www']['pm.max_spare_servers'] = '15' config['www']['pm.max_spare_servers'] = '15'
config['www']['request_terminate_timeout'] = '300' config['www']['request_terminate_timeout'] = '300'
config['www']['pm'] = 'ondemand' config['www']['pm'] = 'ondemand'
config['www']['chdir'] = '/' config['www']['chdir'] = '/'
config['www']['prefix'] = '/var/run/php' config['www']['prefix'] = '/var/run/php'
config['www']['listen'] = 'php73-fpm.sock' config['www']['listen'] = 'php73-fpm.sock'
config['www']['listen.mode'] = '0660' config['www']['listen.mode'] = '0660'
config['www']['listen.backlog'] = '32768' config['www']['listen.backlog'] = '32768'
config['www']['catch_workers_output'] = 'yes' config['www']['catch_workers_output'] = 'yes'
with codecs.open('/etc/php/7.3/fpm/pool.d/www.conf', with codecs.open('/etc/php/7.3/fpm/pool.d/www.conf',
encoding='utf-8', mode='w') as configfile: encoding='utf-8', mode='w') as configfile:
Log.debug(self, "writting PHP 7.3 configuration into " Log.debug(self, "writting PHP 7.3 configuration into "
"/etc/php/7.3/fpm/pool.d/www.conf") "/etc/php/7.3/fpm/pool.d/www.conf")
config.write(configfile) config.write(configfile)
with open("/etc/php/7.3/fpm/pool.d/www.conf", with open("/etc/php/7.3/fpm/pool.d/www.conf",
encoding='utf-8', mode='a') as myfile: encoding='utf-8', mode='a') as myfile:
myfile.write("\nphp_admin_value[open_basedir] " myfile.write("\nphp_admin_value[open_basedir] "
"= \"/var/www/:/usr/share/php/:" "= \"/var/www/:/usr/share/php/:"
"/tmp/:/var/run/nginx-cache/:" "/tmp/:/var/run/nginx-cache/:"
"/dev/shm:/dev/urandom\"\n") "/dev/shm:/dev/urandom\"\n")
# Generate /etc/php/7.3/fpm/pool.d/www-two.conf # Generate /etc/php/7.3/fpm/pool.d/www-two.conf
WOFileUtils.copyfile(self, "/etc/php/7.3/fpm/pool.d/www.conf", WOFileUtils.copyfile(self, "/etc/php/7.3/fpm/pool.d/www.conf",
"/etc/php/7.3/fpm/pool.d/www-two.conf") "/etc/php/7.3/fpm/pool.d/www-two.conf")
WOFileUtils.searchreplace(self, "/etc/php/7.3/fpm/pool.d/" WOFileUtils.searchreplace(self, "/etc/php/7.3/fpm/pool.d/"
"www-two.conf", "[www]", "[www-two]") "www-two.conf", "[www]", "[www-two]")
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read('/etc/php/7.3/fpm/pool.d/www-two.conf') config.read('/etc/php/7.3/fpm/pool.d/www-two.conf')
config['www-two']['listen'] = 'php73-two-fpm.sock' config['www-two']['listen'] = 'php73-two-fpm.sock'
with open('/etc/php/7.3/fpm/pool.d/www-two.conf', with open('/etc/php/7.3/fpm/pool.d/www-two.conf',
encoding='utf-8', mode='w') as confifile: encoding='utf-8', mode='w') as confifile:
Log.debug(self, "writting PHP7.3 configuration into " Log.debug(self, "writting PHP7.3 configuration into "
"/etc/php/7.3/fpm/pool.d/www-two.conf") "/etc/php/7.3/fpm/pool.d/www-two.conf")
config.write(confifile) config.write(confifile)
# Generate /etc/php/7.3/fpm/pool.d/debug.conf # Generate /etc/php/7.3/fpm/pool.d/debug.conf
WOFileUtils.copyfile(self, "/etc/php/7.3/fpm/pool.d/www.conf", WOFileUtils.copyfile(self, "/etc/php/7.3/fpm/pool.d/www.conf",
"/etc/php/7.3/fpm/pool.d/debug.conf") "/etc/php/7.3/fpm/pool.d/debug.conf")
WOFileUtils.searchreplace(self, "/etc/php/7.3/fpm/pool.d/" WOFileUtils.searchreplace(self, "/etc/php/7.3/fpm/pool.d/"
"debug.conf", "[www]", "[debug]") "debug.conf", "[www]", "[debug]")
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read('/etc/php/7.3/fpm/pool.d/debug.conf') config.read('/etc/php/7.3/fpm/pool.d/debug.conf')
config['debug']['listen'] = '127.0.0.1:9173' config['debug']['listen'] = '127.0.0.1:9173'
config['debug']['rlimit_core'] = 'unlimited' config['debug']['rlimit_core'] = 'unlimited'
config['debug']['slowlog'] = '/var/log/php/7.3/slow.log' config['debug']['slowlog'] = '/var/log/php/7.3/slow.log'
config['debug']['request_slowlog_timeout'] = '10s' config['debug']['request_slowlog_timeout'] = '10s'
with open('/etc/php/7.3/fpm/pool.d/debug.conf', with open('/etc/php/7.3/fpm/pool.d/debug.conf',
encoding='utf-8', mode='w') as confifile: encoding='utf-8', mode='w') as confifile:
Log.debug(self, "writting PHP 7.3 configuration into " Log.debug(self, "writting PHP 7.3 configuration into "
"/etc/php/7.3/fpm/pool.d/debug.conf") "/etc/php/7.3/fpm/pool.d/debug.conf")
config.write(confifile) config.write(confifile)
with open("/etc/php/7.3/fpm/pool.d/debug.conf", with open("/etc/php/7.3/fpm/pool.d/debug.conf",
encoding='utf-8', mode='a') as myfile: encoding='utf-8', mode='a') as myfile:
myfile.write("php_admin_value[xdebug.profiler_output_dir] " myfile.write("php_admin_value[xdebug.profiler_output_dir] "
"= /tmp/ \nphp_admin_value[xdebug.profiler_" "= /tmp/ \nphp_admin_value[xdebug.profiler_"
"output_name] = cachegrind.out.%p-%H-%R " "output_name] = cachegrind.out.%p-%H-%R "
"\nphp_admin_flag[xdebug.profiler_enable" "\nphp_admin_flag[xdebug.profiler_enable"
"_trigger] = on \nphp_admin_flag[xdebug." "_trigger] = on \nphp_admin_flag[xdebug."
"profiler_enable] = off\n") "profiler_enable] = off\n")
# Disable xdebug # Disable xdebug
if not WOShellExec.cmd_exec(self, "grep -q \';zend_extension\'" if not WOShellExec.cmd_exec(self, "grep -q \';zend_extension\'"
" /etc/php/7.3/mods-available" " /etc/php/7.3/mods-available"
"/xdebug.ini"): "/xdebug.ini"):
WOFileUtils.searchreplace(self, "/etc/php/7.3/" WOFileUtils.searchreplace(self, "/etc/php/7.3/"
"mods-available/" "mods-available/"
"xdebug.ini", "xdebug.ini",
"zend_extension", "zend_extension",
";zend_extension") ";zend_extension")
# PHP and Debug pull configuration # PHP and Debug pull configuration
if not os.path.exists('{0}22222/htdocs/fpm/status/' if not os.path.exists('{0}22222/htdocs/fpm/status/'
.format(WOVariables.wo_webroot)): .format(WOVariables.wo_webroot)):
Log.debug(self, 'Creating directory ' Log.debug(self, 'Creating directory '
'{0}22222/htdocs/fpm/status/ ' '{0}22222/htdocs/fpm/status/ '
.format(WOVariables.wo_webroot)) .format(WOVariables.wo_webroot))
os.makedirs('{0}22222/htdocs/fpm/status/' os.makedirs('{0}22222/htdocs/fpm/status/'
.format(WOVariables.wo_webroot)) .format(WOVariables.wo_webroot))
open('{0}22222/htdocs/fpm/status/debug73' open('{0}22222/htdocs/fpm/status/debug73'
.format(WOVariables.wo_webroot), .format(WOVariables.wo_webroot),
encoding='utf-8', mode='a').close() encoding='utf-8', mode='a').close()
open('{0}22222/htdocs/fpm/status/php73' open('{0}22222/htdocs/fpm/status/php73'
.format(WOVariables.wo_webroot), .format(WOVariables.wo_webroot),
encoding='utf-8', mode='a').close() encoding='utf-8', mode='a').close()
# Write info.php # Write info.php
if not os.path.exists('{0}22222/htdocs/php/' if not os.path.exists('{0}22222/htdocs/php/'
.format(WOVariables.wo_webroot)): .format(WOVariables.wo_webroot)):
Log.debug(self, 'Creating directory ' Log.debug(self, 'Creating directory '
'{0}22222/htdocs/php/ ' '{0}22222/htdocs/php/ '
.format(WOVariables.wo_webroot)) .format(WOVariables.wo_webroot))
os.makedirs('{0}22222/htdocs/php' os.makedirs('{0}22222/htdocs/php'
.format(WOVariables.wo_webroot)) .format(WOVariables.wo_webroot))
with open("{0}22222/htdocs/php/info.php" with open("{0}22222/htdocs/php/info.php"
.format(WOVariables.wo_webroot), .format(WOVariables.wo_webroot),
encoding='utf-8', mode='w') as myfile: encoding='utf-8', mode='w') as myfile:
myfile.write("<?php\nphpinfo();\n?>") myfile.write("<?php\nphpinfo();\n?>")
WOFileUtils.chown(self, "{0}22222" WOFileUtils.chown(self, "{0}22222"
.format(WOVariables.wo_webroot), .format(WOVariables.wo_webroot),
WOVariables.wo_php_user, WOVariables.wo_php_user,
WOVariables.wo_php_user, recursive=True) WOVariables.wo_php_user, recursive=True)
WOGit.add(self, ["/etc/php"], msg="Adding PHP into Git") WOGit.add(self, ["/etc/php"], msg="Adding PHP into Git")
WOService.restart_service(self, 'php7.3-fpm') WOService.restart_service(self, 'php7.3-fpm')
# create mysql config if it doesn't exist # create mysql config if it doesn't exist
if set(WOVariables.wo_mysql).issubset(set(apt_packages)): if set(WOVariables.wo_mysql).issubset(set(apt_packages)):