Browse Source

Added php7.0 post configuration

master
Prabuddha Chakraborty 9 years ago
parent
commit
ea5f7fb756
  1. 130
      ee/cli/plugins/stack.py

130
ee/cli/plugins/stack.py

@ -933,7 +933,7 @@ class EEStackController(CementBaseController):
"profiler_enable] = off\n")
# Disable xdebug
EEFileUtils.searchreplace(self, "/etc/php/5.6/mods-available/"
EEFileUtils.searchreplace(self, "/etc/php/mods-available/"
"xdebug.ini",
"zend_extension",
";zend_extension")
@ -975,6 +975,134 @@ class EEStackController(CementBaseController):
EEGit.add(self, ["/etc/php5.6"], msg="Adding PHP into Git")
EEService.restart_service(self, 'php5.6-fpm')
#preconfiguration for php7.0
if set(EEVariables.ee_php7_0).issubset(set(apt_packages)):
# Create log directories
if not os.path.exists('/var/log/php/7.0/'):
Log.debug(self, 'Creating directory /var/log/php/7.0/')
os.makedirs('/var/log/php/7.0/')
# Parse etc/php/7.0/fpm/php.ini
config = configparser.ConfigParser()
Log.debug(self, "configuring php file /etc/php/7.0/fpm/php.ini")
config.read('/etc/php/7.0/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'] = EEVariables.ee_timezone
with open('/etc/php/7.0/fpm/php.ini',
encoding='utf-8', mode='w') as configfile:
Log.debug(self, "Writting php configuration into "
"/etc/php/7.0/fpm/php.ini")
config.write(configfile)
# Parse /etc/php/7.0/fpm/php-fpm.conf
config = configparser.ConfigParser()
Log.debug(self, "configuring php file"
"/etc/php/7.0/fpm/php-fpm.conf")
config.read_file(codecs.open("/etc/php/7.0/fpm/php-fpm.conf",
"r", "utf8"))
config['global']['error_log'] = '/var/log/php/7.0/fpm.log'
config.remove_option('global', 'include')
config['global']['log_level'] = 'notice'
config['global']['include'] = '/etc/php/7.0/fpm/pool.d/*.conf'
with codecs.open('/etc/php/7.0/fpm/php-fpm.conf',
encoding='utf-8', mode='w') as configfile:
Log.debug(self, "writting php5 configuration into "
"/etc/php/7.0/fpm/php-fpm.conf")
config.write(configfile)
# Parse /etc/php/7.0/fpm/pool.d/www.conf
config = configparser.ConfigParser()
config.read_file(codecs.open('/etc/php/7.0/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:9070'
with codecs.open('/etc/php/7.0/fpm/pool.d/www.conf',
encoding='utf-8', mode='w') as configfile:
Log.debug(self, "writting PHP5 configuration into "
"/etc/php/7.0/fpm/pool.d/www.conf")
config.write(configfile)
# Generate /etc/php/7.0/fpm/pool.d/debug.conf
EEFileUtils.copyfile(self, "/etc/php/7.0/fpm/pool.d/www.conf",
"/etc/php/7.0/fpm/pool.d/debug.conf")
EEFileUtils.searchreplace(self, "/etc/php/7.0/fpm/pool.d/"
"debug.conf", "[www]", "[debug]")
config = configparser.ConfigParser()
config.read('/etc/php/7.0/fpm/pool.d/debug.conf')
config['debug']['listen'] = '127.0.0.1:9170'
config['debug']['rlimit_core'] = 'unlimited'
config['debug']['slowlog'] = '/var/log/php/7.0/slow.log'
config['debug']['request_slowlog_timeout'] = '10s'
with open('/etc/php/7.0/fpm/pool.d/debug.conf',
encoding='utf-8', mode='w') as confifile:
Log.debug(self, "writting PHP5 configuration into "
"/etc/php/7.0/fpm/pool.d/debug.conf")
config.write(confifile)
with open("/etc/php/7.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
EEFileUtils.searchreplace(self, "/etc/php/mods-available/"
"xdebug.ini",
"zend_extension",
";zend_extension")
# PHP and Debug pull configuration
if not os.path.exists('{0}22222/htdocs/fpm/status/'
.format(EEVariables.ee_webroot)):
Log.debug(self, 'Creating directory '
'{0}22222/htdocs/fpm/status/ '
.format(EEVariables.ee_webroot))
os.makedirs('{0}22222/htdocs/fpm/status/'
.format(EEVariables.ee_webroot))
open('{0}22222/htdocs/fpm/status/debug'
.format(EEVariables.ee_webroot),
encoding='utf-8', mode='a').close()
open('{0}22222/htdocs/fpm/status/php'
.format(EEVariables.ee_webroot),
encoding='utf-8', mode='a').close()
# Write info.php
if not os.path.exists('{0}22222/htdocs/php/'
.format(EEVariables.ee_webroot)):
Log.debug(self, 'Creating directory '
'{0}22222/htdocs/php/ '
.format(EEVariables.ee_webroot))
os.makedirs('{0}22222/htdocs/php'
.format(EEVariables.ee_webroot))
with open("{0}22222/htdocs/php/info.php"
.format(EEVariables.ee_webroot),
encoding='utf-8', mode='w') as myfile:
myfile.write("<?php\nphpinfo();\n?>")
EEFileUtils.chown(self, "{0}22222"
.format(EEVariables.ee_webroot),
EEVariables.ee_php_user,
EEVariables.ee_php_user, recursive=True)
EEGit.add(self, ["/etc/php7.0"], msg="Adding PHP into Git")
EEService.restart_service(self, 'php7.0-fpm')
if set(EEVariables.ee_mysql).issubset(set(apt_packages)):
# TODO: Currently we are using, we need to remove it in future

Loading…
Cancel
Save