Almost there, don't use this yet
This commit is contained in:
@@ -258,7 +258,6 @@ class WOStackController(CementBaseController):
|
||||
'/etc/nginx/common')
|
||||
os.makedirs('/etc/nginx/common')
|
||||
|
||||
# http2 = ("http2" if set(["nginx-mainline"]).issubset(set(apt_packages)) else "spdy")
|
||||
data = dict(webroot=WOVariables.wo_webroot)
|
||||
Log.debug(self, 'Writting the nginx configuration to '
|
||||
'file /etc/nginx/common/acl.conf')
|
||||
@@ -750,213 +749,75 @@ class WOStackController(CementBaseController):
|
||||
"'$http_host \"$request\" $status $body_bytes_sent '\n"
|
||||
"'\"$http_referer\" \"$http_user_agent\"';\n")
|
||||
|
||||
if (WOVariables.wo_platform_distro == 'debian' or WOVariables.wo_platform_codename == 'precise') and set(WOVariables.wo_php).issubset(set(apt_packages)):
|
||||
# Create log directories
|
||||
if not os.path.exists('/var/log/php5/'):
|
||||
Log.debug(self, 'Creating directory /var/log/php5/')
|
||||
os.makedirs('/var/log/php5/')
|
||||
|
||||
# For debian install xdebug
|
||||
|
||||
if (WOVariables.wo_platform_distro == "debian" and
|
||||
WOVariables.wo_platform_codename == 'wheezy'):
|
||||
WOShellExec.cmd_exec(self, "pecl install xdebug")
|
||||
|
||||
with open("/etc/php5/mods-available/xdebug.ini",
|
||||
encoding='utf-8', mode='a') as myfile:
|
||||
myfile.write("zend_extension=/usr/lib/php5/20131226/"
|
||||
"xdebug.so\n")
|
||||
|
||||
WOFileUtils.create_symlink(self, ["/etc/php5/"
|
||||
"mods-available/xdebug.ini",
|
||||
"/etc/php5/fpm/conf.d"
|
||||
"/20-xedbug.ini"])
|
||||
|
||||
# Parse etc/php5/fpm/php.ini
|
||||
config = configparser.ConfigParser()
|
||||
Log.debug(self, "configuring php file /etc/php5/fpm/php.ini")
|
||||
config.read('/etc/php5/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']['date.timezone'] = WOVariables.wo_timezone
|
||||
with open('/etc/php5/fpm/php.ini',
|
||||
encoding='utf-8', mode='w') as configfile:
|
||||
Log.debug(self, "Writting php configuration into "
|
||||
"/etc/php5/fpm/php.ini")
|
||||
config.write(configfile)
|
||||
|
||||
#configure /etc/php5/fpm/php-fpm.conf
|
||||
data = dict(pid="/run/php5-fpm.pid", error_log="/var/log/php5/fpm.log",
|
||||
include="/etc/php5/fpm/pool.d/*.conf")
|
||||
Log.debug(self, "writting php configuration into "
|
||||
"/etc/php5/fpm/php-fpm.conf")
|
||||
wo_php_fpm = open('/etc/php5/fpm/php-fpm.conf',
|
||||
encoding='utf-8', mode='w')
|
||||
self.app.render((data), 'php-fpm.mustache', out=wo_php_fpm)
|
||||
wo_php_fpm.close()
|
||||
|
||||
|
||||
# Parse /etc/php5/fpm/pool.d/www.conf
|
||||
config = configparser.ConfigParser()
|
||||
config.read_file(codecs.open('/etc/php5/fpm/pool.d/www.conf',
|
||||
"r", "utf8"))
|
||||
config['www']['ping.path'] = '/ping'
|
||||
config['www']['pm.status_path'] = '/status'
|
||||
config['www']['pm.max_requests'] = '500'
|
||||
config['www']['pm.max_children'] = '100'
|
||||
config['www']['pm.start_servers'] = '20'
|
||||
config['www']['pm.min_spare_servers'] = '10'
|
||||
config['www']['pm.max_spare_servers'] = '30'
|
||||
config['www']['request_terminate_timeout'] = '300'
|
||||
config['www']['pm'] = 'ondemand'
|
||||
config['www']['listen'] = '127.0.0.1:9000'
|
||||
with codecs.open('/etc/php5/fpm/pool.d/www.conf',
|
||||
encoding='utf-8', mode='w') as configfile:
|
||||
Log.debug(self, "writting PHP5 configuration into "
|
||||
"/etc/php5/fpm/pool.d/www.conf")
|
||||
config.write(configfile)
|
||||
|
||||
# Generate /etc/php5/fpm/pool.d/debug.conf
|
||||
WOFileUtils.copyfile(self, "/etc/php5/fpm/pool.d/www.conf",
|
||||
"/etc/php5/fpm/pool.d/debug.conf")
|
||||
WOFileUtils.searchreplace(self, "/etc/php5/fpm/pool.d/"
|
||||
"debug.conf", "[www]", "[debug]")
|
||||
config = configparser.ConfigParser()
|
||||
config.read('/etc/php5/fpm/pool.d/debug.conf')
|
||||
config['debug']['listen'] = '127.0.0.1:9001'
|
||||
config['debug']['rlimit_core'] = 'unlimited'
|
||||
config['debug']['slowlog'] = '/var/log/php5/slow.log'
|
||||
config['debug']['request_slowlog_timeout'] = '10s'
|
||||
with open('/etc/php5/fpm/pool.d/debug.conf',
|
||||
encoding='utf-8', mode='w') as confifile:
|
||||
Log.debug(self, "writting PHP5 configuration into "
|
||||
"/etc/php5/fpm/pool.d/debug.conf")
|
||||
config.write(confifile)
|
||||
|
||||
with open("/etc/php5/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
|
||||
WOFileUtils.searchreplace(self, "/etc/php5/mods-available/"
|
||||
"xdebug.ini",
|
||||
"zend_extension",
|
||||
";zend_extension")
|
||||
|
||||
# PHP and Debug pull configuration
|
||||
if not os.path.exists('{0}22222/htdocs/fpm/status/'
|
||||
.format(WOVariables.wo_webroot)):
|
||||
Log.debug(self, 'Creating directory '
|
||||
'{0}22222/htdocs/fpm/status/ '
|
||||
.format(WOVariables.wo_webroot))
|
||||
os.makedirs('{0}22222/htdocs/fpm/status/'
|
||||
.format(WOVariables.wo_webroot))
|
||||
open('{0}22222/htdocs/fpm/status/debug'
|
||||
.format(WOVariables.wo_webroot),
|
||||
encoding='utf-8', mode='a').close()
|
||||
open('{0}22222/htdocs/fpm/status/php'
|
||||
.format(WOVariables.wo_webroot),
|
||||
encoding='utf-8', mode='a').close()
|
||||
|
||||
# Write info.php
|
||||
if not os.path.exists('{0}22222/htdocs/php/'
|
||||
.format(WOVariables.wo_webroot)):
|
||||
Log.debug(self, 'Creating directory '
|
||||
'{0}22222/htdocs/php/ '
|
||||
.format(WOVariables.wo_webroot))
|
||||
os.makedirs('{0}22222/htdocs/php'
|
||||
.format(WOVariables.wo_webroot))
|
||||
|
||||
with open("{0}22222/htdocs/php/info.php"
|
||||
.format(WOVariables.wo_webroot),
|
||||
encoding='utf-8', mode='w') as myfile:
|
||||
myfile.write("<?php\nphpinfo();\n?>")
|
||||
|
||||
WOFileUtils.chown(self, "{0}22222"
|
||||
.format(WOVariables.wo_webroot),
|
||||
WOVariables.wo_php_user,
|
||||
WOVariables.wo_php_user, recursive=True)
|
||||
|
||||
WOGit.add(self, ["/etc/php5"], msg="Adding PHP into Git")
|
||||
WOService.restart_service(self, 'php5-fpm')
|
||||
|
||||
|
||||
if (WOVariables.wo_platform_codename == 'trusty' or WOVariables.wo_platform_codename == 'xenial' or WOVariables.wo_platform_codename == 'bionic'):
|
||||
# Create log directories
|
||||
if not os.path.exists('/var/log/php/5.6/'):
|
||||
Log.debug(self, 'Creating directory /var/log/php/5.6/')
|
||||
os.makedirs('/var/log/php/5.6/')
|
||||
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/')
|
||||
|
||||
# Parse etc/php/5.6/fpm/php.ini
|
||||
# Parse etc/php/7.2/fpm/php.ini
|
||||
config = configparser.ConfigParser()
|
||||
Log.debug(self, "configuring php file /etc/php/5.6/fpm/php.ini")
|
||||
config.read('/etc/php/5.6/fpm/php.ini')
|
||||
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']['date.timezone'] = WOVariables.wo_timezone
|
||||
with open('/etc/php/5.6/fpm/php.ini',
|
||||
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/5.6/fpm/php.ini")
|
||||
"/etc/php/7.2/fpm/php.ini")
|
||||
config.write(configfile)
|
||||
|
||||
# Parse /etc/php/5.6/fpm/php-fpm.conf
|
||||
data = dict(pid="/run/php/php5.6-fpm.pid", error_log="/var/log/php/5.6/fpm.log",
|
||||
include="/etc/php/5.6/fpm/pool.d/*.conf")
|
||||
# Parse /etc/php/7.2/fpm/php-fpm.conf
|
||||
data = dict(pid="/run/php/php7.2-fpm.pid", error_log="/var/log/php/7.2/fpm.log",
|
||||
include="/etc/php/7.2/fpm/pool.d/*.conf")
|
||||
Log.debug(self, "writting php5 configuration into "
|
||||
"/etc/php/5.6/fpm/php-fpm.conf")
|
||||
wo_php_fpm = open('/etc/php/5.6/fpm/php-fpm.conf',
|
||||
"/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')
|
||||
self.app.render((data), 'php-fpm.mustache', out=wo_php_fpm)
|
||||
wo_php_fpm.close()
|
||||
|
||||
# Parse /etc/php/5.6/fpm/pool.d/www.conf
|
||||
# Parse /etc/php/7.2/fpm/pool.d/www.conf
|
||||
config = configparser.ConfigParser()
|
||||
config.read_file(codecs.open('/etc/php/5.6/fpm/pool.d/www.conf',
|
||||
config.read_file(codecs.open('/etc/php/7.2/fpm/pool.d/www.conf',
|
||||
"r", "utf8"))
|
||||
config['www']['ping.path'] = '/ping'
|
||||
config['www']['pm.status_path'] = '/status'
|
||||
config['www']['pm.max_requests'] = '500'
|
||||
config['www']['pm.max_children'] = '100'
|
||||
config['www']['pm.start_servers'] = '20'
|
||||
config['www']['pm.min_spare_servers'] = '10'
|
||||
config['www']['pm.max_spare_servers'] = '30'
|
||||
config['www']['request_terminate_timeout'] = '300'
|
||||
config['www']['pm.max_requests'] = '100'
|
||||
config['www']['pm.max_children'] = '25'
|
||||
config['www']['pm.start_servers'] = '5'
|
||||
config['www']['pm.min_spare_servers'] = '2'
|
||||
config['www']['pm.max_spare_servers'] = '5'
|
||||
config['www']['request_terminate_timeout'] = '100'
|
||||
config['www']['pm'] = 'ondemand'
|
||||
config['www']['listen'] = '127.0.0.1:9000'
|
||||
with codecs.open('/etc/php/5.6/fpm/pool.d/www.conf',
|
||||
config['www']['listen'] = '127.0.0.1:9072'
|
||||
with codecs.open('/etc/php/7.2/fpm/pool.d/www.conf',
|
||||
encoding='utf-8', mode='w') as configfile:
|
||||
Log.debug(self, "writting PHP5 configuration into "
|
||||
"/etc/php/5.6/fpm/pool.d/www.conf")
|
||||
Log.debug(self, "Writing PHP 7.2 configuration into "
|
||||
"/etc/php/7.2/fpm/pool.d/www.conf")
|
||||
config.write(configfile)
|
||||
|
||||
# Generate /etc/php/5.6/fpm/pool.d/debug.conf
|
||||
WOFileUtils.copyfile(self, "/etc/php/5.6/fpm/pool.d/www.conf",
|
||||
"/etc/php/5.6/fpm/pool.d/debug.conf")
|
||||
WOFileUtils.searchreplace(self, "/etc/php/5.6/fpm/pool.d/"
|
||||
# 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]", "[debug]")
|
||||
config = configparser.ConfigParser()
|
||||
config.read('/etc/php/5.6/fpm/pool.d/debug.conf')
|
||||
config['debug']['listen'] = '127.0.0.1:9001'
|
||||
config.read('/etc/php/7.2/fpm/pool.d/debug.conf')
|
||||
config['debug']['listen'] = '127.0.0.1:9172'
|
||||
config['debug']['rlimit_core'] = 'unlimited'
|
||||
config['debug']['slowlog'] = '/var/log/php/5.6/slow.log'
|
||||
config['debug']['slowlog'] = '/var/log/php/7.2/slow.log'
|
||||
config['debug']['request_slowlog_timeout'] = '10s'
|
||||
with open('/etc/php/5.6/fpm/pool.d/debug.conf',
|
||||
with open('/etc/php/7.2/fpm/pool.d/debug.conf',
|
||||
encoding='utf-8', mode='w') as confifile:
|
||||
Log.debug(self, "writting PHP5 configuration into "
|
||||
"/etc/php/5.6/fpm/pool.d/debug.conf")
|
||||
"/etc/php/7.2/fpm/pool.d/debug.conf")
|
||||
config.write(confifile)
|
||||
|
||||
with open("/etc/php/5.6/fpm/pool.d/debug.conf",
|
||||
with open("/etc/php/7.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_"
|
||||
@@ -966,8 +827,8 @@ class WOStackController(CementBaseController):
|
||||
"profiler_enable] = off\n")
|
||||
|
||||
# Disable xdebug
|
||||
if not WOShellExec.cmd_exec(self, "grep -q \';zend_extension\' /etc/php/5.6/mods-available/xdebug.ini"):
|
||||
WOFileUtils.searchreplace(self, "/etc/php/5.6/mods-available/"
|
||||
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/mods-available/"
|
||||
"xdebug.ini",
|
||||
"zend_extension",
|
||||
";zend_extension")
|
||||
@@ -1007,7 +868,7 @@ class WOStackController(CementBaseController):
|
||||
WOVariables.wo_php_user, recursive=True)
|
||||
|
||||
WOGit.add(self, ["/etc/php"], msg="Adding PHP into Git")
|
||||
WOService.restart_service(self, 'php5.6-fpm')
|
||||
WOService.restart_service(self, 'php7.2-fpm')
|
||||
|
||||
#PHP7.0 configuration for debian
|
||||
if (WOVariables.wo_platform_codename == 'jessie' ) and set(WOVariables.wo_php72).issubset(set(apt_packages)):
|
||||
@@ -1143,9 +1004,9 @@ class WOStackController(CementBaseController):
|
||||
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']['post_max_size'] = '64M'
|
||||
config['PHP']['upload_max_filesize'] = '64M'
|
||||
config['PHP']['max_execution_time'] = '30'
|
||||
config['PHP']['date.timezone'] = WOVariables.wo_timezone
|
||||
with open('/etc/php/7.2/fpm/php.ini',
|
||||
encoding='utf-8', mode='w') as configfile:
|
||||
@@ -1169,12 +1030,12 @@ class WOStackController(CementBaseController):
|
||||
"r", "utf8"))
|
||||
config['www']['ping.path'] = '/ping'
|
||||
config['www']['pm.status_path'] = '/status'
|
||||
config['www']['pm.max_requests'] = '500'
|
||||
config['www']['pm.max_children'] = '100'
|
||||
config['www']['pm.start_servers'] = '20'
|
||||
config['www']['pm.min_spare_servers'] = '10'
|
||||
config['www']['pm.max_spare_servers'] = '30'
|
||||
config['www']['request_terminate_timeout'] = '300'
|
||||
config['www']['pm.max_requests'] = '100'
|
||||
config['www']['pm.max_children'] = '25'
|
||||
config['www']['pm.start_servers'] = '5'
|
||||
config['www']['pm.min_spare_servers'] = '2'
|
||||
config['www']['pm.max_spare_servers'] = '5'
|
||||
config['www']['request_terminate_timeout'] = '100'
|
||||
config['www']['pm'] = 'ondemand'
|
||||
config['www']['listen'] = '127.0.0.1:9072'
|
||||
with codecs.open('/etc/php/7.2/fpm/pool.d/www.conf',
|
||||
@@ -1256,14 +1117,6 @@ class WOStackController(CementBaseController):
|
||||
|
||||
|
||||
if set(WOVariables.wo_mysql).issubset(set(apt_packages)):
|
||||
# TODO: Currently we are using, we need to remove it in future
|
||||
# config = configparser.ConfigParser()
|
||||
# config.read('/etc/mysql/my.cnf')
|
||||
# config['mysqld']['wait_timeout'] = 30
|
||||
# config['mysqld']['interactive_timeout'] = 60
|
||||
# config['mysqld']['performance_schema'] = 0
|
||||
# with open('/etc/mysql/my.cnf', 'w') as configfile:
|
||||
# config.write(configfile)
|
||||
if not os.path.isfile("/etc/mysql/my.cnf"):
|
||||
config = ("[mysqld]\nwait_timeout = 30\n"
|
||||
"interactive_timeout=60\nperformance_schema = 0"
|
||||
@@ -1283,7 +1136,6 @@ class WOStackController(CementBaseController):
|
||||
except CommandExecutionError as e:
|
||||
Log.error(self, "Unable to update MySQL file")
|
||||
|
||||
# Set MySQLTuner permission
|
||||
WOFileUtils.chmod(self, "/usr/bin/mysqltuner", 0o775)
|
||||
|
||||
WOGit.add(self, ["/etc/mysql"], msg="Adding MySQL into Git")
|
||||
|
||||
Reference in New Issue
Block a user