From cc043bd76ec3794221d4e4f7112d0698cdd0a143 Mon Sep 17 00:00:00 2001 From: jeroenlaylo Date: Mon, 3 Dec 2018 20:17:22 +0100 Subject: [PATCH] Almost there, don't use this yet --- backup | 85 -------------- install | 118 +++++++++++--------- wo/cli/plugins/stack.py | 242 ++++++++-------------------------------- 3 files changed, 115 insertions(+), 330 deletions(-) delete mode 100644 backup diff --git a/backup b/backup deleted file mode 100644 index ff7aae7..0000000 --- a/backup +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/bash -############################# -### WordOps backup script ### -############################# - -# Blue -function wo_lib_echo() -{ - echo $(tput setaf 4)$@$(tput sgr0) -} -# White -function wo_lib_echo_info() -{ - echo $(tput setaf 7)$@$(tput sgr0) -} -# Red -function wo_lib_echo_fail() -{ - echo $(tput setaf 1)$@$(tput sgr0) -} - -# Check whether we are running as UID 0 -if [[ $EUID -ne 0 ]]; then - wo_lib_echo_fail "WordOps backup requires elevated privileges" - wo_lib_echo_fail "Call it as root: wget -qO backup wordops.se/curedata && sudo bash backup" - exit 100 -fi - -# Capture errors -function wo_lib_error() -{ - echo "[ `date` ] $(tput setaf 1)$@$(tput sgr0)" - exit $2 -} - -# Define variables for later use -wo_branch=$1 -readonly wo_log_dir=/var/log/wo/ -readonly wo_backup_log=/var/log/wo/backup.log -readonly wo_linux_distro=$(lsb_release -i | awk '{print $3}') -readonly wo_distro_version=$(lsb_release -sc) - -# Checking linux distro -if [ "$wo_linux_distro" != "Ubuntu" ] && [ "$wo_linux_distro" != "Debian" ]; then - wo_lib_echo_fail "WordOps (wo) only supports Ubuntu and Debian at the moment." - wo_lib_echo_fail "If you are feeling adventurous, you are free to fork WordOps to support" - wo_lib_echo_fail "other Linux distributions and perhaps even Unix deratives." - wo_lib_echo_fail "WordOps (wo) only supports Ubuntu 14.04/16.04/18.04, Debian 8.x and Debian 9.x" - exit 100 -fi - -# WordOps (wo) only supports Ubuntu/Debian versions that are eligible for support -lsb_release -d | egrep -e "14.04|16.04|18.04|jessie|stretch" &>> /dev/null -if [ "$?" -ne "0" ]; then - wo_lib_echo_fail "WordOps (wo) only supports Ubuntu 14.04/16.04/18.04, Debian 8.x and Debian 9.x" - exit 100 -fi - -# Check whether the log file is in place and otherwise create it -if [ ! -f $wo_backup_log ]; then - - wo_lib_echo "Creating the WordOps (wo) backup log, just a second..." - - # Touch/create two empty log files within the wo_log_dir - touch /var/log/wo/backup.log - - # Set the ACL to only allow access by the root user and block others - chmod 700 /var/log/wo/backup.log || wo_lib_error "Whoops, there was an error setting the permissions on the WordOps (wo) backup log file, exit status " $? -fi - -function wo_install_duplicity() -{ - if [ ! -f $wo_duplicity_bin ]; then - if [ "$wo_linux_distro" == "Ubuntu" ]; then - apt-get -y install duplicity python-pip || wo_lib_error "There was an error during dependency installation, exit status " 1 - elif [ "$wo_linux_distro" == "Debian" ]; then - apt-get -y install duplicity python-pip || wo_lib_error "There was an error during dependency installation, exit status " 1 - fi - fi -} - -function wo_backup_databases() -{ - # -} diff --git a/install b/install index 4bdbacb..8b8851a 100644 --- a/install +++ b/install @@ -6,6 +6,8 @@ ### --- ### 1. VARIABLES AND DECLARATIONS ### 2. PREPARE FOR INSTALLATION +### 3. INSTALLATION +### 4. ### # 1 - Set the CLI output colors @@ -62,6 +64,7 @@ fi # 1 - Define variables for later use ### wo_branch=$1 +migration=0 readonly wo_version_old="2.2.3" readonly wo_version_new="3.8.6" readonly wo_log_dir=/var/log/wo/ @@ -129,17 +132,22 @@ function wo_sync_db() mkdir -p /var/lib/wo # Backup the nginx directory - tar -cvf - /etc/nginx /var/lib/ee/ee.db | pigz -9 > /var/lib/wo/ee-nginx.tgz - + tar -cvf - /etc/nginx /etc/ee /var/lib/ee | pigz -9 > /var/lib/wo/ee-backup.tgz + # Copy the EasyEngine database - cp /var/lib/ee/ee.db /var/lib/wo/dbase.db + cp /var/lib/ee/ee.db /var/lib/wo/dbase-ee.db + + # Set the migration variable for the closing text + migration=1 ### # Clean WO installation ### elif [ ! -f /var/lib/wo/dbase.db ]; then + # Create the directory holding the WordOps database mkdir -p /var/lib/wo + # Create an empty database for WordOps echo "CREATE TABLE sites ( id INTEGER PRIMARY KEY AUTOINCREMENT, sitename UNIQUE, @@ -159,6 +167,11 @@ function wo_sync_db() php_version VARCHAR );" | sqlite3 /var/lib/wo/dbase.db + if [ -f /var/lib/wo/dbase-ee.db]; then + # Copy the main EasyEngine database over since we are migrating + cp /var/lib/wo/dbase-ee.db /var/lib/wo/dbase.db + fi + # Check site is enable/live or disable for site in $(ls /etc/nginx/sites-available/ | grep -v default); do @@ -186,11 +199,9 @@ function wo_sync_db() elif [ "$wo_site_current_type" = "WPSINGLE BASIC" ]; then wo_site_current="wp" wo_site_current_cache="basic" - elif [ "$wo_site_current_type" = "WPSINGLE WP SUPER CACHE" ]; then wo_site_current="wp" wo_site_current_cache="wpsc" - elif [ "$wo_site_current_type" = "WPSINGLE FAST CGI" ] || [ "$wo_site_current_type" = "WPSINGLE FASTCGI" ]; then wo_site_current="wp" wo_site_current_cache="wpfc" @@ -199,11 +210,9 @@ function wo_sync_db() elif [ "$wo_site_current_type" = "WPSUBDIR BASIC" ]; then wo_site_current="wpsubdir" wo_site_current_cache="basic" - elif [ "$wo_site_current_type" = "WPSUBDIR WP SUPER CACHE" ]; then wo_site_current="wpsubdir" wo_site_current_cache="wpsc" - elif [ "$wo_site_current_type" = "WPSUBDIR FAST CGI" ] || [ "$wo_site_current_type" = "WPSUBDIR FASTCGI" ]; then wo_site_current="wpsubdir" wo_site_current_cache="wpfc" @@ -212,11 +221,9 @@ function wo_sync_db() elif [ "$wo_site_current_type" = "WPSUBDOMAIN BASIC" ]; then wo_site_current="wpsubdomain" wo_site_current_cache="basic" - elif [ "$wo_site_current_type" = "WPSUBDOMAIN WP SUPER CACHE" ]; then wo_site_current="wpsubdomain" wo_site_current_cache="wpsc" - elif [ "$wo_site_current_type" = "WPSUBDOMAIN FAST CGI" ] || [ "$wo_site_current_type" = "WPSUBDOMAIN FASTCGI" ]; then wo_site_current="wpsubdomain" wo_site_current_cache="wpfc" @@ -239,6 +246,21 @@ function wo_sync_db() echo "ALTER TABLE sites ADD COLUMN php_version varchar DEFAULT \"$wo_php_version\";" | sqlite3 /var/lib/wo/dbase.db fi + ### + # Copy the upstream config + ### + if [ -f /etc/nginx/conf.d/upstream.conf ]; then + wo_lib_echo "Replace the PHP ports for PHP 7.2" + # Copy the previous upstream.conf + cp /etc/nginx/conf.d/upstream.conf /etc/nginx/conf.d/upstream.bak + # Replace the ports for PHP 7.2 + sed -i "s/127.0.0.1:9000/127.0.0.1:9072/g" /etc/nginx/conf.d/upstream.conf &>> /dev/null + sed -i "s/127.0.0.1:9070/127.0.0.1:9072/g" /etc/nginx/conf.d/upstream.conf &>> /dev/null + # Replace the ports for debug PHP 7.2 + sed -i "s/127.0.0.1:9001/127.0.0.1:9172/g" /etc/nginx/conf.d/upstream.conf &>> /dev/null + sed -i "s/127.0.0.1:9170/127.0.0.1:9172/g" /etc/nginx/conf.d/upstream.conf &>> /dev/null + fi + ### # ee-acme-sh by VirtuBox, https://virtubox.net/ ### @@ -561,7 +583,19 @@ if [ -f /etc/ImageMagick/policy.xml ] # Support PFS if [ -f /etc/nginx/nginx.conf ]; then - sed -i 's/HIGH:!aNULL:!MD5:!kEDH;/ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-CHACHA20-POLY1305:EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH;/' /etc/nginx/nginx.conf + # Replace the default ciphers + sed -i 's/HIGH:!aNULL:!MD5:!kEDH;/ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-CHACHA20-POLY1305:EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH;/' /etc/nginx/nginx.conf + # Replace the EasyEngine ciphers + sed -i 's/ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:ECDHE-RSA-DES-CBC3-SHA:ECDHE-ECDSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA; +/ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-CHACHA20-POLY1305:EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH;/' /etc/nginx/nginx.conf + # Change the TLS protocols + if [ "$wo_distro_version" == "bionic" ]; then + # Bionic supports TLSv1.3, so let's enable that + sed -i 's/TLSv1 TLSv1.1 TLSv1.2;/TLSv1.2 TLSv1.3;/' /etc/nginx/nginx.conf + elif + # If != Bionic then enable only TLSv1.2 + sed -i 's/TLSv1 TLSv1.1 TLSv1.2;/TLSv1.2;/' /etc/nginx/nginx.conf + fi fi #Fix for SSL cert --all @@ -569,7 +603,7 @@ if [ -f /etc/ImageMagick/policy.xml ] if [[ $? -eq 0 ]]; then crontab -l > /var/spool/cron/cron-backup.txt #backup cron before editing crontab -l | sed '/--min_expiry_limit/d' | crontab - - /bin/bash -c "crontab -l 2> /dev/null | { cat; echo -e \"\n0 0 * * 0 wo site update --le=renew --all 2> /dev/null # Renew all letsencrypt SSL cert. Set by EasyEngine\"; } | crontab -" + /bin/bash -c "crontab -l 2> /dev/null | { cat; echo -e \"\n0 0 * * 0 wo site update --le=renew --all 2> /dev/null # Renew all letsencrypt SSL cert. Set by WordOps\"; } | crontab -" fi } @@ -585,7 +619,7 @@ function wo_git_init() git add -A . git commit -am "Updated Nginx" > /dev/null fi - # EasyEngine under git version control + # WordOps under git version control cd /etc/wo if [ ! -d /etc/wo/.git ]; then git init > /dev/null @@ -606,32 +640,7 @@ function wo_git_init() } # Update WordOps -if [ -f /usr/local/sbin/easyengine ]; then - # Check old EasyEngine version - ee version | grep ${wo_version_old} &>> /dev/null - if [[ $? -ne 0 ]]; then - wo_lib_echo "WordOps/EasyEngine $wo_version_old not found on your system" | tee -ai $wo_install_log - wo_lib_echo "Updating your EasyEngine to $wo_version_old for compability" | tee -ai $wo_install_log - wget -q https://raw.githubusercontent.com/EasyEngine/easyengine/old-stable/bin/update && bash update - if [[ $? -ne 0 ]]; then - wo_lib_echo_fail "Unable to update EasyEngine to $wo_version_old, exit status = " $? - exit 100 - fi - fi - read -p "Update WordOps to $wo_version_new (y/n): " wo_ans - if [ "$wo_ans" = "y" ] || [ "$wo_ans" = "Y" ]; then - wo_install_dep | tee -ai $wo_install_log - wo_sync_db 2&>>1 $WO_INSTALL_LOG - secure_wo_db | tee -ai $WO_INSTALL_LOG - wo_upgrade_php | tee -ai $wo_install_log - wo_install | tee -ai $wo_install_log - wo_update | tee -ai $wo_install_log - wo_update_latest | tee -ai $wo_install_log - wo_git_init | tee -ai $wo_install_log - else - wo_lib_error "Not updating WordOps to $wo_version_new, exit status = " 1 - fi -elif [ ! -f /usr/local/bin/wo ]; then +if [ ! -f /usr/local/bin/wo ]; then wo_lib_echo "Installing depedencies" | tee -ai $wo_install_log wo_install_dep | tee -ai $wo_install_log wo_lib_echo "Installing WordOps $wo_branch" | tee -ai $wo_install_log @@ -653,11 +662,7 @@ else wo_update_latest | tee -ai $wo_install_log wo_git_init | tee -ai $wo_install_log service nginx reload &>> /dev/null - if [ "$wo_distro_version" == "trusty" ]; then - service php5.6-fpm restart &>> /dev/null - else - service php5-fpm restart &>> /dev/null - fi + service php7.2-fpm restart &>> /dev/null wo_update_wp_cli | tee -ai $wo_install_log else wo_lib_error "Not updating WordOps to $wo_version_new, exit status = " 1 @@ -666,12 +671,25 @@ else wo_lib_error "You already have WordOps $wo_version_new, exit status = " 1 fi fi + wo sync | tee -ai $WO_INSTALL_LOG -echo -wo_lib_echo "For WordOps (wo) auto completion, run the following command" -echo -wo_lib_echo_info "source /etc/bash_completion.d/wo_auto.rc" -echo -wo_lib_echo "Yay! WordOps (wo) installed/updated successfully" -wo_lib_echo "WordOps (wo) help: https://wordops.org/docs" \ No newline at end of file +if [ "$migration" -eq "1" ]; then + echo + wo_lib_echo "The migration from EasyEngine to WordOps was succesfull!" + wo_lib_echo "The EasyEngine backup files can be found in /var/lib/wo/ee-backup.tgz" + echo + wo_lib_echo_info "For autocompletion, run the following command:" + wo_lib_echo_info "source /etc/bash_completion.d/wo_auto.rc" + echo + wo_lib_echo "WordOps (wo) help: https://wordops.org/docs" +else + echo + wo_lib_echo "For WordOps (wo) auto completion, run the following command" + echo + wo_lib_echo_info "source /etc/bash_completion.d/wo_auto.rc" + echo + wo_lib_echo "Yay! WordOps (wo) installed/updated successfully" + wo_lib_echo "WordOps (wo) help: https://wordops.org/docs" +fi + diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index 97bb621..c7334d4 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -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("") - - 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")