Browse Source

Merge branch 'feature/v3.5.0' into develop

master
Prabuddha Chakraborty 9 years ago
parent
commit
090f459deb
  1. 0
      .github/CONTRIBUTING.md
  2. 6
      .github/ISSUE_TEMPLATE.md
  3. 5
      CHANGELOG.txt
  4. 40
      config/bash_completion.d/ee_auto.rc
  5. 26
      docs/ee.8
  6. 210
      ee/cli/plugins/debug.py
  7. 108
      ee/cli/plugins/info.py
  8. 4
      ee/cli/plugins/models.py
  9. 142
      ee/cli/plugins/site.py
  10. 191
      ee/cli/plugins/site_functions.py
  11. 9
      ee/cli/plugins/sitedb.py
  12. 542
      ee/cli/plugins/stack.py
  13. 141
      ee/cli/plugins/stack_services.py
  14. 34
      ee/cli/plugins/stack_upgrade.py
  15. 68
      ee/cli/templates/locations-php7.mustache
  16. 5
      ee/cli/templates/php-fpm.mustache
  17. 10
      ee/cli/templates/php7.mustache
  18. 56
      ee/cli/templates/redis-php7.mustache
  19. 1
      ee/cli/templates/siteinfo.mustache
  20. 10
      ee/cli/templates/upstream.mustache
  21. 49
      ee/cli/templates/virtualconf-php7.mustache
  22. 3
      ee/cli/templates/virtualconf.mustache
  23. 31
      ee/cli/templates/w3tc-php7.mustache
  24. 35
      ee/cli/templates/wpcommon-php7.mustache
  25. 37
      ee/cli/templates/wpfc-php7.mustache
  26. 31
      ee/cli/templates/wpsc-php7.mustache
  27. 4
      ee/core/services.py
  28. 39
      ee/core/variables.py
  29. 59
      install
  30. 2
      setup.py

0
CONTRIBUTING.md → .github/CONTRIBUTING.md

6
.github/ISSUE_TEMPLATE.md

@ -0,0 +1,6 @@
Please attach the output of following command when open a new support request.
- [ ] lsb_release -a
- [ ] ee -v
- [ ] ee info
- [ ] wp --allow-root --info

5
CHANGELOG.txt

@ -1,3 +1,8 @@
v3.5.0 - Feb 24, 2016
- Added PHP 7.0 support for Ubuntu(Trusty)
- Dual support for PHP 5.6 + PHP 7.0
- Fixed minor issues
v3.4.1 - Jan 20, 2016
- Fixed and update ee stack install --nginx/--nginxmainline
- Fixed --letsencrypt minor issues

40
config/bash_completion.d/ee_auto.rc

@ -29,7 +29,7 @@ _ee_complete()
# IF YOU HAD ANOTHER CONTROLLER, YOU'D HANDLE THAT HERE
"debug")
COMPREPLY=( $(compgen \
-W "$(command find /etc/nginx/sites-enabled/ -type l -printf "%P " 2> /dev/null) --nginx --php --fpm --mysql -i --interactive --all --import-slow-log --import-slow-log-interval= --nginx=off --php=off --fpm=off --mysql=off --all=off " \
-W "$(command find /etc/nginx/sites-enabled/ -type l -printf "%P " 2> /dev/null) --nginx --php --php7 --fpm --fpm7 --mysql -i --interactive --all --import-slow-log --import-slow-log-interval= --nginx=off --php=off --php7=off --fpm=off --fpm7=off --mysql=off --all=off " \
-- $cur) )
;;
@ -53,7 +53,7 @@ _ee_complete()
"info")
COMPREPLY=( $(compgen \
-W "--mysql --php --nginx" \
-W "--mysql --php --php7 --nginx" \
-- $cur) )
;;
@ -74,17 +74,17 @@ _ee_complete()
# HANDLE EVERYTHING AFTER THE THIRD LEVEL NAMESPACE
"install" | "purge" | "remove" )
COMPREPLY=( $(compgen \
-W "--pagespeed --web --admin --mail --nginx --nginxmainline --php --mysql --postfix --wpcli --phpmyadmin --adminer --utils --all --mailscanner --hhvm --redis --phpredisadmin" \
-W "--pagespeed --web --admin --mail --nginx --nginxmainline --php --php7 --mysql --postfix --wpcli --phpmyadmin --adminer --utils --all --mailscanner --hhvm --redis --phpredisadmin" \
-- $cur) )
;;
"upgrade" )
COMPREPLY=( $(compgen \
-W "--web --mail --nginx --php --mysql --postfix --all --hhvm --php56 --no-prompt --wpcli" \
-W "--web --mail --nginx --php --php7 --mysql --postfix --all --hhvm --php56 --no-prompt --wpcli" \
-- $cur) )
;;
"start" | "stop" | "reload" | "restart" | "status")
COMPREPLY=( $(compgen \
-W "--nginx --php --mysql --postfix --memcache --dovecot --redis" \
-W "--nginx --php --php7 --mysql --postfix --memcache --dovecot --redis" \
-- $cur) )
;;
"migrate")
@ -142,7 +142,7 @@ _ee_complete()
;;
esac
if [ ${COMP_WORDS[1]} == "debug" ] && ([ "$prev" != "--start" ] && [ "$prev" != "--nginx" ] && [ "$prev" != "--php" ] && [ "$prev" != "--fpm" ] && [ "$prev" != "--mysql" ] && [ "$prev" != "-i" ] && [ "$prev" != "--interactive" ] && [ "$prev" != "--import-slow-log" ] && [ "$prev" != "--stop" ]); then
if [ ${COMP_WORDS[1]} == "debug" ] && ([ "$prev" != "--start" ] && [ "$prev" != "--nginx" ] && [ "$prev" != "--php" ] && [ "$prev" != "--php7" ] && [ "$prev" != "--fpm" ] && [ "$prev" != "--fpm7" ] && [ "$prev" != "--mysql" ] && [ "$prev" != "-i" ] && [ "$prev" != "--interactive" ] && [ "$prev" != "--import-slow-log" ] && [ "$prev" != "--stop" ]); then
retlist="--all --wp --rewrite -i --all=off --wp=off --rewrite=off"
ret="${retlist[@]/$prev}"
COMPREPLY=( $(compgen \
@ -165,13 +165,13 @@ _ee_complete()
"create")
COMPREPLY=( $(compgen \
-W "--user --pass --email --html --php --mysql --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc --hhvm --proxy= --pagespeed --wpredis --letsencrypt -le" \
-W "--user --pass --email --html --php --php7 --mysql --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc --hhvm --proxy= --pagespeed --wpredis --letsencrypt -le" \
-- $cur) )
;;
"update")
COMPREPLY=( $(compgen \
-W "--password --php --mysql --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc --hhvm --hhvm=off --pagespeed --pagespeed=off --wpredis --letsencrypt --letsencrypt=off --letsencrypt=renew" \
-W "--password --php --php7 --mysql --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc --hhvm --hhvm=off --pagespeed --pagespeed=off --wpredis --letsencrypt --letsencrypt=off --letsencrypt=renew" \
-- $cur) )
;;
"delete")
@ -217,9 +217,9 @@ _ee_complete()
"--wp")
if [ ${COMP_WORDS[1]} != "debug" ]; then
if [ ${COMP_WORDS[2]} == "create" ]; then
retlist="--wp --wpsc --w3tc --wpfc --pagespeed --hhvm --user --email --pass --wpredis --letsencrypt"
retlist="--wp --wpsc --w3tc --wpfc --pagespeed --hhvm --user --email --pass --wpredis --letsencrypt --php7"
elif [ ${COMP_WORDS[2]} == "update" ]; then
retlist="--wp --w3tc --wpfc --wpsc --pagespeed --hhvm --pagespeed=off --hhvm=off --wpredis --letsencrypt --letsencrypt=off --letsencrypt=renew"
retlist="--wp --w3tc --wpfc --wpsc --php7 --php7=off --pagespeed --hhvm --pagespeed=off --hhvm=off --wpredis --letsencrypt --letsencrypt=off --letsencrypt=renew"
else
retlist=""
fi
@ -236,9 +236,9 @@ _ee_complete()
"--wpsubdir" | "--wpsubdomain")
if [ ${COMP_WORDS[1]} != "debug" ]; then
if [ ${COMP_WORDS[2]} == "create" ]; then
retlist="--wpsc --w3tc --wpfc --pagespeed --hhvm --user --email --pass --wpredis --letsencrypt"
retlist="--wpsc --w3tc --wpfc --pagespeed --hhvm --user --email --pass --wpredis --letsencrypt --php7"
elif [ ${COMP_WORDS[2]} == "update" ]; then
retlist="--w3tc --wpfc --wpsc --pagespeed --hhvm --pagespeed=off --hhvm=off --wpredis --letsencrypt --letsencrypt=off --letsencrypt=renew"
retlist="--w3tc --wpfc --wpsc --php7 --php7=off --pagespeed --hhvm --pagespeed=off --hhvm=off --wpredis --letsencrypt --letsencrypt=off --letsencrypt=renew"
else
retlist=""
fi
@ -254,7 +254,7 @@ _ee_complete()
"--pagespeed" | "--hhvm" | "--wpredis" | "--w3tc" | "--wpfc" | "--wpsc" | "--wpsubdir" | "--wpsubdomain" | "--user" | "--pass" | "--email" | "--wp")
if [ ${COMP_WORDS[2]} == "create" ]; then
retlist="--user --pass --email --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc --hhvm --pagespeed --experimenal --wpredis --letsencrypt"
retlist="--user --pass --email --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc --hhvm --pagespeed --experimenal --wpredis --php7 --letsencrypt "
else
retlist=""
fi
@ -267,7 +267,7 @@ _ee_complete()
"--pagespeed" | "--hhvm" | "--wpredis" | "--w3tc" | "--wpfc")
if [ ${COMP_WORDS[2]} == "update" ]; then
retlist="--password --php --mysql --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc --hhvm --hhvm=off --pagespeed --pagespeed=off --experimenal --wpredis --letsencrypt --letsencrypt=off --letsencrypt=renew"
retlist="--password --php --php7 --mysql --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc --hhvm --hhvm=off --pagespeed --pagespeed=off --experimenal --wpredis --letsencrypt --letsencrypt=off --letsencrypt=renew"
else
retlist=""
fi
@ -278,15 +278,15 @@ _ee_complete()
-- $cur) )
;;
"--web" | "--admin" | "--mail" | "--nginx" | "--php" | "--mysql" | "--postfix" | "--wpcli" | "--phpmyadmin" | "--adminer" | "--utils" | "--memcache" | "--dovecot" | "--redis | --phpredisadmin")
"--web" | "--admin" | "--mail" | "--nginx" | "--php" | "--php7" | "--mysql" | "--postfix" | "--wpcli" | "--phpmyadmin" | "--adminer" | "--utils" | "--memcache" | "--dovecot" | "--redis | --phpredisadmin")
if [[ ${COMP_WORDS[2]} == "install" || ${COMP_WORDS[2]} == "purge" || ${COMP_WORDS[2]} == "remove" ]]; then
retlist="--web --admin --mail --nginx --php --mysql --postfix --wpcli --phpmyadmin --adminer --utils --memcache --dovecot --redis --phpredisadmin"
retlist="--web --admin --mail --nginx --php --php7 --mysql --postfix --wpcli --phpmyadmin --adminer --utils --memcache --dovecot --redis --phpredisadmin"
elif [[ ${COMP_WORDS[2]} == "start" || ${COMP_WORDS[2]} == "reload" || ${COMP_WORDS[2]} == "restart" || ${COMP_WORDS[2]} == "stop" ]]; then
retlist="--nginx --php --mysql --postfix --memcache --dovecot --redis"
retlist="--nginx --php --php7 --mysql --postfix --memcache --dovecot --redis"
elif [[ ${COMP_WORDS[1]} == "debug" ]]; then
retlist="--start --nginx --php --fpm --mysql -i --interactive -stop --import-slow-log --import-slow-log-interval= -"
retlist="--start --nginx --php --php7 --fpm --fpm7 --mysql -i --interactive -stop --import-slow-log --import-slow-log-interval= -"
if [[ $prev == '--mysql' ]]; then
retlist="--start --nginx --php --fpm --mysql -i --interactive --stop --import-slow-log"
retlist="--start --nginx --php --php7 --fpm --fpm7 --mysql -i --interactive --stop --import-slow-log"
fi
elif [[ ${COMP_WORDS[1]} == "log" ]]; then
if [ ${COMP_WORDS[2]} == "show" ]; then
@ -369,7 +369,7 @@ _ee_complete()
case "$mprev" in
"--user" | "--email" | "--pass")
if [ ${COMP_WORDS[2]} == "create" ]; then
retlist="--user --pass --email --html --php --mysql --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc --hhvm --pagespeed --wpredis --letsencrypt"
retlist="--user --pass --email --html --php --php7 --mysql --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc --hhvm --pagespeed --wpredis --letsencrypt"
fi
ret="${retlist[@]/$prev}"
COMPREPLY=( $(compgen \

26
docs/ee.8

@ -5,15 +5,15 @@
.SH SYNOPSIS
ee [ --version | --help | info | stack | site | debug | update | clean | import_slow_log | log | secure | sync]
.TP
ee stack [ install | remove | purge | migrate | upgrade] [ --web | --mail | --all | --nginx | --nginxmainline | --php | --mysql | --admin | --postfix | --mailscanner | --adminer | --redis | --hhvm | --phpmyadmin | --phpredisadmin | --wpcli | --utils ]
ee stack [ install | remove | purge | migrate | upgrade] [ --web | --mail | --all | --nginx | --nginxmainline | --php | --php7 | --mysql | --admin | --postfix | --mailscanner | --adminer | --redis | --hhvm | --phpmyadmin | --phpredisadmin | --wpcli | --utils ]
.TP
ee stack [ status | start | stop | reload | restart ] [--all | --nginx | --php | --mysql | --devcot | --web | --postfix | --memcache | --redis]
ee stack [ status | start | stop | reload | restart ] [--all | --nginx | --php | --php7 |--mysql | --devcot | --web | --postfix | --memcache | --redis]
.TP
ee site [ list | info | show | enable | disable | edit | cd | show ] [ example.com ]
.TP
ee site create example.com [ --html | --php | --mysql] [[--wp | --wpsubdir | --wpsubdomain ] [--wpsc | --w3tc | --wpfc | --wpredis | --hhvm | --pagespeed | --letsencrypt/-le]]
ee site create example.com [ --html | --php | --php7 | --mysql] [[--wp | --wpsubdir | --wpsubdomain ] [--wpsc | --w3tc | --wpfc | --wpredis | --hhvm | --pagespeed | --letsencrypt/-le]]
.TP
ee site update example.com [ --php | --mysql] [[--wp | --wpsubdir | --wpsubdomain ] [--wpsc | --w3tc | --wpfc | --wpredis | --hhvm | --pagespeed ] [--password] [--letsencrypt=on/off/renew]]
ee site update example.com [ --php | --php7 |--mysql] [[--wp | --wpsubdir | --wpsubdomain ] [--wpsc | --w3tc | --wpfc | --wpredis | --hhvm | --pagespeed ] [--password] [--letsencrypt=on/off/renew]]
.TP
ee site delete example.com [--db | --files | --all | --no-prompt | --force/-f ]
.TP
@ -46,19 +46,19 @@ Display easyengine (ee) help.
.TP
.B stack
.TP
.B install [ --all | --web | --mail | --nginx | --php | --mysql | --redis | --postfix | --adminer | --phpmyadmin | --phpredismyadmin | --wpcli | --utils ]
.B install [ --all | --web | --mail | --nginx | --php | --php7 |--mysql | --redis | --postfix | --adminer | --phpmyadmin | --phpredismyadmin | --wpcli | --utils ]
.br
Install Nginx PHP5 MySQL Postfix stack Packages if not used with
.br
any options.Installs specific package if used with option.
.TP
.B remove [ --all | --web | --mail | --nginx | --php | --mysql | --redis | --postfix | --adminer | --phpmyadmin | --phpredismyadmin | --wpcli | --utils ]
.B remove [ --all | --web | --mail | --nginx | --php | --php7 |--mysql | --redis | --postfix | --adminer | --phpmyadmin | --phpredismyadmin | --wpcli | --utils ]
.br
Remove Nginx PHP5 MySQL Postfix stack Packages if not used with
.br
any options. Remove specific package if used with option.
.TP
.B purge [ --all | --web | --mail | --nginx | --php | --mysql | --redis | --postfix | --adminer | --phpmyadmin | --phpredismyadmin | --wpcli | --utils ]
.B purge [ --all | --web | --mail | --nginx | --php | --php7 |--mysql | --redis | --postfix | --adminer | --phpmyadmin | --phpredismyadmin | --wpcli | --utils ]
.br
Purge Nginx PHP5 MySQL Postfix stack Packages if not used with any
.br
@ -129,13 +129,13 @@ Disable site by Destroying softlink with site file in
.br
Edit NGINX configuration of site.
.TP
.B create [ example.com ] [ --html | --php | --mysql] [[--wp | --wpsubdir | --wpsubdomain ] [--wpsc | --w3tc | --wpfc | --wpredis | --hhvm | --pagespeed ]]
.B create [ example.com ] [ --html | --php | --php7 |--mysql] [[--wp | --wpsubdir | --wpsubdomain ] [--wpsc | --w3tc | --wpfc | --wpredis | --hhvm | --pagespeed ]]
.br
Create new site according to given options. If no options provided
.br
create static site with html only.
.TP
.B update [ example.com ] [ --html | --php | --mysql] [[--wp | --wpsubdir | --wpsubdomain ] [ --wpsc | --w3tc | --wpfc | --wpredis | --hhvm | --pagespeed ] [--password]]
.B update [ example.com ] [ --html | --php | --php7 |--mysql] [[--wp | --wpsubdir | --wpsubdomain ] [ --wpsc | --w3tc | --wpfc | --wpredis | --hhvm | --pagespeed ] [--password]]
.br
Update site configuration according to specified options.
.TP
@ -143,7 +143,7 @@ Update site configuration according to specified options.
.br
Delete site i.e webroot, database, ad configuration permanently.
.TP
.B debug [ -i | --nginx=on/off | --php=on/off | --mysql=on/off | --rewrite=on/off | --fpm=on/off ]
.B debug [ -i | --nginx=on/off | --php=on/off | --php7=on/off | --mysql=on/off | --rewrite=on/off | --fpm=on/off | --fpm7=on/off ]
.br
Starts server level debugging. If this is used without arguments it will start debugging
.br
@ -182,6 +182,10 @@ used with ee debug command. used to start or stop nginx debugging.
.br
used with ee debug command. used to start or stop php debugging.
.TP
.B --php7=on/off
.br
used with ee debug command. used to start or stop php7 debugging.
.TP
.B --mysql=on/off
.br
used with ee debug command. used to start or stop mysql debugging.
@ -287,7 +291,7 @@ Install, activate, configure Nginx-helper and Redis Object Cache Plugin, Configu
Install, activate Nginx-helper and configure NGINX for HHVM.
.SH FILES
.br
/etc/easyengine/ee.conf
/etc/ee/ee.conf
.SH BUGS
Report bugs at <http://github.com/rtCamp/easyengine/issues/>
.SH AUTHOR

210
ee/cli/plugins/debug.py

@ -2,6 +2,7 @@
from cement.core.controller import CementBaseController, expose
from cement.core import handler, hook
from ee.core.aptget import EEAptGet
from ee.core.shellexec import *
from ee.core.mysql import EEMysql
from ee.core.services import EEService
@ -49,6 +50,14 @@ class EEDebugController(CementBaseController):
dict(help='start/stop debugging fastcgi configuration',
action='store' or 'store_const',
choices=('on', 'off'), const='on', nargs='?')),
(['--php7'],
dict(help='start/stop debugging server php 7.0 configuration',
action='store' or 'store_const',
choices=('on', 'off'), const='on', nargs='?')),
(['--fpm7'],
dict(help='start/stop debugging fastcgi 7.0 configuration',
action='store' or 'store_const',
choices=('on', 'off'), const='on', nargs='?')),
(['--mysql'],
dict(help='start/stop debugging mysql server',
action='store' or 'store_const',
@ -118,7 +127,7 @@ class EEDebugController(CementBaseController):
Log.info(self, "Nginx debug connection already disabled")
# start site specific debug
elif (self.app.pargs.nginx == 'on'and self.app.pargs.site_name):
elif (self.app.pargs.nginx == 'on' and self.app.pargs.site_name):
config_path = ("/etc/nginx/sites-available/{0}"
.format(self.app.pargs.site_name))
if os.path.isfile(config_path):
@ -167,6 +176,7 @@ class EEDebugController(CementBaseController):
def debug_php(self):
"""Start/Stop PHP debug"""
# PHP global debug start
if (self.app.pargs.php == 'on' and not self.app.pargs.site_name):
if not (EEShellExec.cmd_exec(self, "sed -n \"/upstream php"
"{/,/}/p \" /etc/nginx/"
@ -184,20 +194,20 @@ class EEDebugController(CementBaseController):
nc.savef('/etc/nginx/conf.d/upstream.conf')
# Enable xdebug
EEFileUtils.searchreplace(self, "/etc/php5/mods-available/"
"xdebug.ini",
";zend_extension",
"zend_extension")
EEFileUtils.searchreplace(self, "/etc/{0}/mods-available/".format("php" if EEVariables.ee_platform_codename == 'trusty' else "php5") +
"xdebug.ini",
";zend_extension",
"zend_extension")
# Fix slow log is not enabled default in PHP5.6
config = configparser.ConfigParser()
config.read('/etc/php5/fpm/pool.d/debug.conf')
config['debug']['slowlog'] = '/var/log/php5/slow.log'
config.read('/etc/{0}/fpm/pool.d/debug.conf'.format("php/5.6" if EEVariables.ee_platform_codename == 'trusty' else "php5"))
config['debug']['slowlog'] = '/var/log/{0}/slow.log'.format("php/5.6" if EEVariables.ee_platform_codename == 'trusty' else "php5")
config['debug']['request_slowlog_timeout'] = '10s'
with open('/etc/php5/fpm/pool.d/debug.conf',
with open('/etc/{0}/fpm/pool.d/debug.conf'.format("php/5.6" if EEVariables.ee_platform_codename == 'trusty' else "php5"),
encoding='utf-8', mode='w') as confifile:
Log.debug(self, "Writting debug.conf configuration into "
"/etc/php5/fpm/pool.d/debug.conf")
"/etc/{0}/fpm/pool.d/debug.conf".format("php/5.6" if EEVariables.ee_platform_codename == 'trusty' else "php5"))
config.write(confifile)
self.trigger_php = True
@ -205,7 +215,7 @@ class EEDebugController(CementBaseController):
else:
Log.info(self, "PHP debug is already enabled")
self.msg = self.msg + ['/var/log/php5/slow.log']
self.msg = self.msg + ['/var/log/{0}/slow.log'.format("php/5.6" if EEVariables.ee_platform_codename == 'trusty' else "php5")]
# PHP global debug stop
elif (self.app.pargs.php == 'off' and not self.app.pargs.site_name):
@ -223,7 +233,7 @@ class EEDebugController(CementBaseController):
nc.savef('/etc/nginx/conf.d/upstream.conf')
# Disable xdebug
EEFileUtils.searchreplace(self, "/etc/php5/mods-available/"
EEFileUtils.searchreplace(self, "/etc/{0}/mods-available/".format("php" if EEVariables.ee_platform_codename == 'trusty' else "php5") +
"xdebug.ini",
"zend_extension",
";zend_extension")
@ -239,44 +249,160 @@ class EEDebugController(CementBaseController):
# PHP5-FPM start global debug
if (self.app.pargs.fpm == 'on' and not self.app.pargs.site_name):
if not EEShellExec.cmd_exec(self, "grep \"log_level = debug\" "
"/etc/php5/fpm/php-fpm.conf"):
"/etc/{0}/fpm/php-fpm.conf".format("php/5.6" if EEVariables.ee_platform_codename == 'trusty' else "php5")):
Log.info(self, "Setting up PHP5-FPM log_level = debug")
config = configparser.ConfigParser()
config.read('/etc/php5/fpm/php-fpm.conf')
config.read('/etc/{0}/fpm/php-fpm.conf'.format("php/5.6" if EEVariables.ee_platform_codename == 'trusty' else "php5"))
config.remove_option('global', 'include')
config['global']['log_level'] = 'debug'
config['global']['include'] = '/etc/php5/fpm/pool.d/*.conf'
with open('/etc/php5/fpm/php-fpm.conf',
config['global']['include'] = '/etc/{0}/fpm/pool.d/*.conf'.format("php/5.6" if EEVariables.ee_platform_codename == 'trusty' else "php5")
with open('/etc/{0}/fpm/php-fpm.conf'.format("php/5.6" if EEVariables.ee_platform_codename == 'trusty' else "php5"),
encoding='utf-8', mode='w') as configfile:
Log.debug(self, "Writting php5-FPM configuration into "
"/etc/php5/fpm/php-fpm.conf")
"/etc/{0}/fpm/php-fpm.conf".format("php/5.6" if EEVariables.ee_platform_codename == 'trusty' else "php5"))
config.write(configfile)
self.trigger_php = True
else:
Log.info(self, "PHP5-FPM log_level = debug already setup")
self.msg = self.msg + ['/var/log/php5/fpm.log']
self.msg = self.msg + ['/var/log/{0}/fpm.log'.format("php/5.6" if EEVariables.ee_platform_codename == 'trusty' else "php5")]
# PHP5-FPM stop global debug
elif (self.app.pargs.fpm == 'off' and not self.app.pargs.site_name):
if EEShellExec.cmd_exec(self, "grep \"log_level = debug\" "
"/etc/php5/fpm/php-fpm.conf"):
"/etc/{0}/fpm/php-fpm.conf".format("php/5.6" if EEVariables.ee_platform_codename == 'trusty' else "php5")):
Log.info(self, "Disabling PHP5-FPM log_level = debug")
config = configparser.ConfigParser()
config.read('/etc/php5/fpm/php-fpm.conf')
config.read('/etc/{0}/fpm/php-fpm.conf'.format("php/5.6" if EEVariables.ee_platform_codename == 'trusty' else "php5"))
config.remove_option('global', 'include')
config['global']['log_level'] = 'notice'
config['global']['include'] = '/etc/php5/fpm/pool.d/*.conf'
with open('/etc/php5/fpm/php-fpm.conf',
config['global']['include'] = '/etc/{0}/fpm/pool.d/*.conf'.format("php/5.6" if EEVariables.ee_platform_codename == 'trusty' else "php5")
with open('/etc/{0}/fpm/php-fpm.conf'.format("php/5.6" if EEVariables.ee_platform_codename == 'trusty' else "php5"),
encoding='utf-8', mode='w') as configfile:
Log.debug(self, "writting php5 configuration into "
"/etc/php5/fpm/php-fpm.conf")
"/etc/{0}/fpm/php-fpm.conf".format("php/5.6" if EEVariables.ee_platform_codename == 'trusty' else "php5"))
config.write(configfile)
self.trigger_php = True
else:
Log.info(self, "PHP5-FPM log_level = debug already disabled")
@expose(hide=True)
def debug_php7(self):
"""Start/Stop PHP debug"""
# PHP global debug start
if (self.app.pargs.php7 == 'on' and not self.app.pargs.site_name):
if EEVariables.ee_platform_codename != 'trusty':
Log.error(self,"PHP 7.0 not supported.")
if not (EEShellExec.cmd_exec(self, "sed -n \"/upstream php7"
"{/,/}/p \" /etc/nginx/"
"conf.d/upstream.conf "
"| grep 9170")):
Log.info(self, "Enabling PHP 7.0 debug")
# Change upstream.conf
nc = NginxConfig()
nc.loadf('/etc/nginx/conf.d/upstream.conf')
nc.set([('upstream','php',), 'server'], '127.0.0.1:9170')
if os.path.isfile("/etc/nginx/common/wpfc-hhvm.conf"):
nc.set([('upstream','hhvm',), 'server'], '127.0.0.1:9170')
nc.savef('/etc/nginx/conf.d/upstream.conf')
# Enable xdebug
EEFileUtils.searchreplace(self, "/etc/php/mods-available/"
"xdebug.ini",
";zend_extension",
"zend_extension")
# Fix slow log is not enabled default in PHP5.6
config = configparser.ConfigParser()
config.read('/etc/php/7.0/fpm/pool.d/debug.conf')
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 debug.conf configuration into "
"/etc/php/7.0/fpm/pool.d/debug.conf")
config.write(confifile)
self.trigger_php = True
self.trigger_nginx = True
else:
Log.info(self, "PHP debug is already enabled")
self.msg = self.msg + ['/var/log/php/7.0/slow.log']
# PHP global debug stop
elif (self.app.pargs.php7 == 'off' and not self.app.pargs.site_name):
if EEShellExec.cmd_exec(self, " sed -n \"/upstream php {/,/}/p\" "
"/etc/nginx/conf.d/upstream.conf "
"| grep 9170"):
Log.info(self, "Disabling PHP 7.0 debug")
# Change upstream.conf
nc = NginxConfig()
nc.loadf('/etc/nginx/conf.d/upstream.conf')
nc.set([('upstream','php',), 'server'], '127.0.0.1:9070')
if os.path.isfile("/etc/nginx/common/wpfc-hhvm.conf"):
nc.set([('upstream','hhvm',), 'server'], '127.0.0.1:8000')
nc.savef('/etc/nginx/conf.d/upstream.conf')
# Disable xdebug
EEFileUtils.searchreplace(self, "/etc/php/mods-available/"
"xdebug.ini",
"zend_extension",
";zend_extension")
self.trigger_php = True
self.trigger_nginx = True
else:
Log.info(self, "PHP 7.0 debug is already disabled")
@expose(hide=True)
def debug_fpm7(self):
"""Start/Stop PHP5-FPM debug"""
# PHP5-FPM start global debug
if (self.app.pargs.fpm7 == 'on' and not self.app.pargs.site_name):
if not EEShellExec.cmd_exec(self, "grep \"log_level = debug\" "
"/etc/php/7.0/fpm/php-fpm.conf"):
Log.info(self, "Setting up PHP7.0-FPM log_level = debug")
config = configparser.ConfigParser()
config.read('/etc/php/7.0/fpm/php-fpm.conf')
config.remove_option('global', 'include')
config['global']['log_level'] = 'debug'
config['global']['include'] = '/etc/php/7.0/fpm/pool.d/*.conf'
with open('/etc/php/7.0/fpm/php-fpm.conf',
encoding='utf-8', mode='w') as configfile:
Log.debug(self, "Writting php7.0-FPM configuration into "
"/etc/php/7.0/fpm/php-fpm.conf")
config.write(configfile)
self.trigger_php = True
else:
Log.info(self, "PHP7.0-FPM log_level = debug already setup")
self.msg = self.msg + ['/var/log/php/7.0/fpm.log']
# PHP5-FPM stop global debug
elif (self.app.pargs.fpm7 == 'off' and not self.app.pargs.site_name):
if EEShellExec.cmd_exec(self, "grep \"log_level = debug\" "
"/etc/php/7.0/fpm/php-fpm.conf"):
Log.info(self, "Disabling PHP7.0-FPM log_level = debug")
config = configparser.ConfigParser()
config.read('/etc/php/7.0/fpm/php-fpm.conf')
config.remove_option('global', 'include')
config['global']['log_level'] = 'notice'
config['global']['include'] = '/etc/php/7.0/fpm/pool.d/*.conf'
with open('/etc/php/7.0/fpm/php-fpm.conf',
encoding='utf-8', mode='w') as configfile:
Log.debug(self, "writting php7.0 configuration into "
"/etc/php/7.0/fpm/php-fpm.conf")
config.write(configfile)
self.trigger_php = True
else:
Log.info(self, "PHP7.0-FPM log_level = debug already disabled")
@expose(hide=True)
def debug_mysql(self):
"""Start/Stop MySQL debug"""
@ -470,9 +596,15 @@ class EEDebugController(CementBaseController):
if self.app.pargs.php:
self.app.pargs.php = 'off'
self.debug_php()
if self.app.pargs.php7:
self.app.pargs.php7 = 'off'
self.debug_php7()
if self.app.pargs.fpm:
self.app.pargs.fpm = 'off'
self.debug_fpm()
if self.app.pargs.fpm7:
self.app.pargs.fpm7 = 'off'
self.debug_fpm7()
if self.app.pargs.mysql:
# MySQL debug will not work for remote MySQL
if EEVariables.ee_mysql_host is "localhost":
@ -494,7 +626,13 @@ class EEDebugController(CementBaseController):
# Reload PHP
if self.trigger_php:
EEService.reload_service(self, 'php5-fpm')
if EEVariables.ee_platform_codename == 'trusty':
if EEAptGet.is_installed(self,'php5.6-fpm'):
EEService.reload_service(self, 'php5.6-fpm')
if EEAptGet.is_installed(self,'php7.0-fpm'):
EEService.reload_service(self, 'php7.0-fpm')
else:
EEService.reload_service(self, 'php5-fpm')
self.app.close(0)
@expose(hide=True)
@ -506,8 +644,8 @@ class EEDebugController(CementBaseController):
self.trigger_nginx = False
self.trigger_php = False
if ((not self.app.pargs.nginx) and (not self.app.pargs.php)
and (not self.app.pargs.fpm) and (not self.app.pargs.mysql)
if ((not self.app.pargs.nginx) and (not self.app.pargs.php) and (not self.app.pargs.php7)
and (not self.app.pargs.fpm) and (not self.app.pargs.fpm7) and (not self.app.pargs.mysql)
and (not self.app.pargs.wp) and (not self.app.pargs.rewrite)
and (not self.app.pargs.all)
and (not self.app.pargs.site_name)
@ -579,6 +717,9 @@ class EEDebugController(CementBaseController):
self.app.pargs.nginx = 'on'
self.app.pargs.php = 'on'
self.app.pargs.fpm = 'on'
if EEVariables.ee_platform_codename == 'trusty' and EEAptGet.is_installed(self,'php7.0-fpm'):
self.app.pargs.php7 = 'on'
self.app.pargs.fpm7 = 'on'
self.app.pargs.mysql = 'on'
self.app.pargs.rewrite = 'on'
@ -588,11 +729,14 @@ class EEDebugController(CementBaseController):
self.app.pargs.nginx = 'off'
self.app.pargs.php = 'off'
self.app.pargs.fpm = 'off'
if EEVariables.ee_platform_codename == 'trusty' and EEAptGet.is_installed(self,'php7.0-fpm'):
self.app.pargs.php7 = 'off'
self.app.pargs.fpm7 = 'off'
self.app.pargs.mysql = 'off'
self.app.pargs.rewrite = 'off'
if ((not self.app.pargs.nginx) and (not self.app.pargs.php)
and (not self.app.pargs.fpm) and (not self.app.pargs.mysql)
if ((not self.app.pargs.nginx) and (not self.app.pargs.php) and (not self.app.pargs.php7)
and (not self.app.pargs.fpm) and (not self.app.pargs.fpm7) and (not self.app.pargs.mysql)
and (not self.app.pargs.wp) and (not self.app.pargs.rewrite)
and self.app.pargs.site_name):
self.app.args.print_help()
@ -606,6 +750,10 @@ class EEDebugController(CementBaseController):
self.debug_php()
if self.app.pargs.fpm:
self.debug_fpm()
if self.app.pargs.php7:
self.debug_php7()
if self.app.pargs.fpm7:
self.debug_fpm7()
if self.app.pargs.mysql:
# MySQL debug will not work for remote MySQL
if EEVariables.ee_mysql_host is "localhost":
@ -626,7 +774,13 @@ class EEDebugController(CementBaseController):
EEService.reload_service(self, 'nginx')
# Reload PHP
if self.trigger_php:
EEService.restart_service(self, 'php5-fpm')
if EEVariables.ee_platform_codename == 'trusty':
if EEAptGet.is_installed(self,'php5.6-fpm'):
EEService.restart_service(self, 'php5.6-fpm')
if EEAptGet.is_installed(self,'php7.0-fpm'):
EEService.restart_service(self, 'php7.0-fpm')
else:
EEService.restart_service(self, 'php5-fpm')
if len(self.msg) > 0:
if not self.app.pargs.interactive:

108
ee/cli/plugins/info.py

@ -2,6 +2,7 @@
from cement.core.controller import CementBaseController, expose
from cement.core import handler, hook
from ee.core.variables import EEVariables
from pynginxconfig import NginxConfig
from ee.core.aptget import EEAptGet
from ee.core.shellexec import EEShellExec
@ -29,6 +30,9 @@ class EEInfoController(CementBaseController):
(['--php'],
dict(help='Get PHP configuration information',
action='store_true')),
(['--php7'],
dict(help='Get PHP 7.0 configuration information',
action='store_true')),
(['--nginx'],
dict(help='Get Nginx configuration information',
action='store_true')),
@ -63,17 +67,91 @@ class EEInfoController(CementBaseController):
@expose(hide=True)
def info_php(self):
"""Display PHP information"""
version = os.popen("php -v | head -n1 | cut -d' ' -f2 |"
version = os.popen("{0} -v 2>/dev/null | head -n1 | cut -d' ' -f2 |".format("php5.6" if EEVariables.ee_platform_codename == 'trusty' else "php") +
" cut -d'+' -f1 | tr -d '\n'").read
config = configparser.ConfigParser()
config.read('/etc/{0}/fpm/php.ini'.format("php/5.6" if EEVariables.ee_platform_codename == 'trusty' else "php5"))
expose_php = config['PHP']['expose_php']
memory_limit = config['PHP']['memory_limit']
post_max_size = config['PHP']['post_max_size']
upload_max_filesize = config['PHP']['upload_max_filesize']
max_execution_time = config['PHP']['max_execution_time']
config.read('/etc/{0}/fpm/pool.d/www.conf'.format("php/5.6" if EEVariables.ee_platform_codename == 'trusty' else "php5"))
www_listen = config['www']['listen']
www_ping_path = config['www']['ping.path']
www_pm_status_path = config['www']['pm.status_path']
www_pm = config['www']['pm']
www_pm_max_requests = config['www']['pm.max_requests']
www_pm_max_children = config['www']['pm.max_children']
www_pm_start_servers = config['www']['pm.start_servers']
www_pm_min_spare_servers = config['www']['pm.min_spare_servers']
www_pm_max_spare_servers = config['www']['pm.max_spare_servers']
www_request_terminate_time = (config['www']
['request_terminate_timeout'])
try:
www_xdebug = (config['www']['php_admin_flag[xdebug.profiler_enable'
'_trigger]'])
except Exception as e:
www_xdebug = 'off'
config.read('/etc/{0}/fpm/pool.d/debug.conf'.format("php/5.6" if EEVariables.ee_platform_codename == 'trusty' else "php5"))
debug_listen = config['debug']['listen']
debug_ping_path = config['debug']['ping.path']
debug_pm_status_path = config['debug']['pm.status_path']
debug_pm = config['debug']['pm']
debug_pm_max_requests = config['debug']['pm.max_requests']
debug_pm_max_children = config['debug']['pm.max_children']
debug_pm_start_servers = config['debug']['pm.start_servers']
debug_pm_min_spare_servers = config['debug']['pm.min_spare_servers']
debug_pm_max_spare_servers = config['debug']['pm.max_spare_servers']
debug_request_terminate = (config['debug']
['request_terminate_timeout'])
try:
debug_xdebug = (config['debug']['php_admin_flag[xdebug.profiler_'
'enable_trigger]'])
except Exception as e:
debug_xdebug = 'off'
data = dict(version=version, expose_php=expose_php,
memory_limit=memory_limit, post_max_size=post_max_size,
upload_max_filesize=upload_max_filesize,
max_execution_time=max_execution_time,
www_listen=www_listen, www_ping_path=www_ping_path,
www_pm_status_path=www_pm_status_path, www_pm=www_pm,
www_pm_max_requests=www_pm_max_requests,
www_pm_max_children=www_pm_max_children,
www_pm_start_servers=www_pm_start_servers,
www_pm_min_spare_servers=www_pm_min_spare_servers,
www_pm_max_spare_servers=www_pm_max_spare_servers,
www_request_terminate_timeout=www_request_terminate_time,
www_xdebug_profiler_enable_trigger=www_xdebug,
debug_listen=debug_listen, debug_ping_path=debug_ping_path,
debug_pm_status_path=debug_pm_status_path,
debug_pm=debug_pm,
debug_pm_max_requests=debug_pm_max_requests,
debug_pm_max_children=debug_pm_max_children,
debug_pm_start_servers=debug_pm_start_servers,
debug_pm_min_spare_servers=debug_pm_min_spare_servers,
debug_pm_max_spare_servers=debug_pm_max_spare_servers,
debug_request_terminate_timeout=debug_request_terminate,
debug_xdebug_profiler_enable_trigger=debug_xdebug)
self.app.render((data), 'info_php.mustache')
@expose(hide=True)
def info_php7(self):
"""Display PHP information"""
version = os.popen("php7.0 -v 2>/dev/null | head -n1 | cut -d' ' -f2 |"
" cut -d'+' -f1 | tr -d '\n'").read
config = configparser.ConfigParser()
config.read('/etc/php5/fpm/php.ini')
config.read('/etc/php/7.0/fpm/php.ini')
expose_php = config['PHP']['expose_php']
memory_limit = config['PHP']['memory_limit']
post_max_size = config['PHP']['post_max_size']
upload_max_filesize = config['PHP']['upload_max_filesize']
max_execution_time = config['PHP']['max_execution_time']
config.read('/etc/php5/fpm/pool.d/www.conf')
config.read('/etc/php/7.0/fpm/pool.d/www.conf')
www_listen = config['www']['listen']
www_ping_path = config['www']['ping.path']
www_pm_status_path = config['www']['pm.status_path']
@ -91,7 +169,7 @@ class EEInfoController(CementBaseController):
except Exception as e:
www_xdebug = 'off'
config.read('/etc/php5/fpm/pool.d/debug.conf')
config.read('/etc/php/7.0/fpm/pool.d/debug.conf')
debug_listen = config['debug']['listen']
debug_ping_path = config['debug']['ping.path']
debug_pm_status_path = config['debug']['pm.status_path']
@ -166,10 +244,12 @@ class EEInfoController(CementBaseController):
def default(self):
"""default function for info"""
if (not self.app.pargs.nginx and not self.app.pargs.php
and not self.app.pargs.mysql):
and not self.app.pargs.mysql and not self.app.pargs.php7):
self.app.pargs.nginx = True
self.app.pargs.php = True
self.app.pargs.mysql = True
if EEAptGet.is_installed(self, 'php7.0-fpm'):
self.app.pargs.php = True
if self.app.pargs.nginx:
if EEAptGet.is_installed(self, 'nginx-common'):
@ -178,10 +258,22 @@ class EEInfoController(CementBaseController):
Log.error(self, "Nginx is not installed")
if self.app.pargs.php:
if EEAptGet.is_installed(self, 'php5-fpm'):
self.info_php()
if EEVariables.ee_platform_codename != 'trusty':
if EEAptGet.is_installed(self, 'php5-fpm'):
self.info_php()
else:
Log.error(self, "PHP5 is not installed")
else:
if EEAptGet.is_installed(self, 'php5.6-fpm'):
self.info_php()
else:
Log.error(self, "PHP5.6 is not installed")
if self.app.pargs.php7:
if EEAptGet.is_installed(self, 'php7.0-fpm'):
self.info_php7()
else:
Log.error(self, "PHP5 is not installed")
Log.error(self, "PHP 7.0 is not installed")
if self.app.pargs.mysql:
if EEShellExec.cmd_exec(self, "mysqladmin ping"):

4
ee/cli/plugins/models.py

@ -30,12 +30,13 @@ class SiteDB(Base):
db_host = Column(String)
is_hhvm = Column(Boolean, unique=False, default=False)
is_pagespeed = Column(Boolean, unique=False, default=False)
php_version = Column(String)
def __init__(self, sitename=None, site_type=None, cache_type=None,
site_path=None, site_enabled=None,
is_ssl=None, storage_fs=None, storage_db=None, db_name=None,
db_user=None, db_password=None, db_host='localhost',
hhvm=None, pagespeed=None):
hhvm=None, pagespeed=None, php_version=None):
self.sitename = sitename
self.site_type = site_type
self.cache_type = cache_type
@ -50,6 +51,7 @@ class SiteDB(Base):
self.db_host = db_host
self.is_hhvm = hhvm
self.is_pagespeed = pagespeed
self.php_version = php_version
# def __repr__(self):
# return '<Site %r>' % (self.site_type)
#

142
ee/cli/plugins/site.py

@ -156,6 +156,7 @@ class EESiteController(CementBaseController):
error_log = "/var/log/nginx/{0}.error.log".format(ee_domain)
ee_site_webroot = ''
php_version = siteinfo.php_version
pagespeed = ("enabled" if siteinfo.is_pagespeed else "disabled")
ssl = ("enabled" if siteinfo.is_ssl else "disabled")
if (ssl == "enabled"):
@ -166,7 +167,7 @@ class EESiteController(CementBaseController):
sslexpiry = ''
data = dict(domain=ee_domain, webroot=ee_site_webroot,
accesslog=access_log, errorlog=error_log,
dbname=ee_db_name, dbuser=ee_db_user,
dbname=ee_db_name, dbuser=ee_db_user,php_version=php_version,
dbpass=ee_db_pass, hhvm=hhvm, pagespeed=pagespeed,
ssl=ssl, sslprovider=sslprovider, sslexpiry= sslexpiry,
type=sitetype + " " + cachetype + " ({0})"
@ -336,6 +337,8 @@ class EESiteCreateController(CementBaseController):
dict(help="create html site", action='store_true')),
(['--php'],
dict(help="create php site", action='store_true')),
(['--php7'],
dict(help="create php 7.0 site", action='store_true')),
(['--mysql'],
dict(help="create mysql site", action='store_true')),
(['--wp'],
@ -441,9 +444,16 @@ class EESiteCreateController(CementBaseController):
data['port'] = port
ee_site_webroot = ""
if stype in ['html', 'php']:
if self.app.pargs.php7:
data = dict(site_name=ee_domain, www_domain=ee_www_domain,
static=True, basic=False, wp=False, w3tc=False,
static=False, basic=False, php7=True, wp=False, w3tc=False,
wpfc=False, wpsc=False, multisite=False,
wpsubdir=False, webroot=ee_site_webroot)
data['basic'] = True
if stype in ['html', 'php' ]:
data = dict(site_name=ee_domain, www_domain=ee_www_domain,
static=True, basic=False, php7=False, wp=False, w3tc=False,
wpfc=False, wpsc=False, multisite=False,
wpsubdir=False, webroot=ee_site_webroot)
@ -477,6 +487,40 @@ class EESiteCreateController(CementBaseController):
if stype == "html" and self.app.pargs.hhvm:
Log.error(self, "Can not create HTML site with HHVM")
if data and self.app.pargs.php7:
if (not self.app.pargs.experimental):
Log.info(self, "PHP7.0 is experimental feature and it may not "
"work with all CSS/JS/Cache of your site.\nDo you wish"
" to install PHP 7.0 now for {0}?".format(ee_domain))
# Check prompt
check_prompt = input("Type \"y\" to continue [n]:")
if check_prompt != "Y" and check_prompt != "y":
Log.info(self, "Not using PHP 7.0 for site.")
data['php7'] = False
data['basic'] = True
php7 = 0
self.app.pargs.php7 = False
else:
data['php7'] = True
php7 = 1
else:
data['php7'] = True
php7 = 1
elif data:
data['php7'] = False
php7 = 0
if (not self.app.pargs.w3tc) and\
(not self.app.pargs.wpfc) and (not self.app.pargs.wpsc) and (not self.app.pargs.wpredis) \
and (not self.app.pargs.hhvm):
data['basic'] = True
#for debug purpose
#for key, value in data.items() :
# print (key, value)
if data and self.app.pargs.hhvm:
if (not self.app.pargs.experimental):
Log.info(self, "HHVM is experimental feature and it may not "
@ -593,8 +637,14 @@ class EESiteCreateController(CementBaseController):
if self.app.pargs.pagespeed:
operateOnPagespeed(self, data)
if data['php7']:
php_version = "7.0"
else:
php_version = "5.6"
addNewSite(self, ee_domain, stype, cache, ee_site_webroot,
hhvm=hhvm, pagespeed=pagespeed)
hhvm=hhvm, pagespeed=pagespeed, php_version=php_version)
# Setup database for MySQL site
if 'ee_db_name' in data.keys() and not data['wp']:
@ -799,6 +849,10 @@ class EESiteUpdateController(CementBaseController):
dict(help="update to html site", action='store_true')),
(['--php'],
dict(help="update to php site", action='store_true')),
(['--php7'],
dict(help="update to php7 site",
action='store' or 'store_const',
choices=('on', 'off'), const='on', nargs='?')),
(['--mysql'],
dict(help="update to mysql site", action='store_true')),
(['--wp'],
@ -848,7 +902,7 @@ class EESiteUpdateController(CementBaseController):
if pargs.html:
Log.error(self, "No site can be updated to html")
if not (pargs.php or
if not (pargs.php or pargs.php7 or
pargs.mysql or pargs.wp or pargs.wpsubdir or
pargs.wpsubdomain or pargs.w3tc or pargs.wpfc or
pargs.wpsc or pargs.hhvm or pargs.pagespeed or pargs.wpredis or pargs.letsencrypt):
@ -877,6 +931,8 @@ class EESiteUpdateController(CementBaseController):
hhvm = None
pagespeed = None
letsencrypt = False
php7 = None
data = dict()
try:
@ -923,9 +979,15 @@ class EESiteUpdateController(CementBaseController):
old_hhvm = check_site.is_hhvm
old_pagespeed = check_site.is_pagespeed
check_ssl = check_site.is_ssl
check_php_version = check_site.php_version
if check_php_version == "7.0":
old_php7 = True
else:
old_php7 = False
if (pargs.password and not (pargs.html or
pargs.php or pargs.mysql or pargs.wp or
pargs.php or pargs.php7 or pargs.mysql or pargs.wp or
pargs.w3tc or pargs.wpfc or pargs.wpsc
or pargs.wpsubdir or pargs.wpsubdomain)):
try:
@ -945,15 +1007,16 @@ class EESiteUpdateController(CementBaseController):
Log.info(self, Log.FAIL + "Can not update HTML site to HHVM")
return 1
if ((stype == 'php' and oldsitetype not in ['html', 'proxy']) or
if ((stype == 'php' and oldsitetype not in ['html', 'proxy', 'php7']) or
# (stype == 'php7' and oldsitetype not in ['html', 'mysql', 'php', 'php7', 'wp', 'wpsubdir', 'wpsubdomain', ]) or
(stype == 'mysql' and oldsitetype not in ['html', 'php',
'proxy']) or
'proxy','php7']) or
(stype == 'wp' and oldsitetype not in ['html', 'php', 'mysql',
'proxy', 'wp']) or
'proxy', 'wp', 'php7']) or
(stype == 'wpsubdir' and oldsitetype in ['wpsubdomain']) or
(stype == 'wpsubdomain' and oldsitetype in ['wpsubdir']) or
(stype == oldsitetype and cache == oldcachetype) and
not pargs.pagespeed):
not (pargs.pagespeed or pargs.php7)):
Log.info(self, Log.FAIL + "can not update {0} {1} to {2} {3}".
format(oldsitetype, oldcachetype, stype, cache))
return 1
@ -996,13 +1059,12 @@ class EESiteUpdateController(CementBaseController):
if stype == 'wpsubdir':
data['wpsubdir'] = True
if pargs.pagespeed or pargs.hhvm:
if pargs.pagespeed or pargs.hhvm or pargs.php7:
if not data:
data = dict(site_name=ee_domain, www_domain=ee_www_domain,
currsitetype=oldsitetype,
currcachetype=oldcachetype,
webroot=ee_site_webroot)
stype = oldsitetype
cache = oldcachetype
if oldsitetype == 'html' or oldsitetype == 'proxy':
@ -1076,6 +1138,14 @@ class EESiteUpdateController(CementBaseController):
data['pagespeed'] = False
pagespeed = False
if pargs.php7 == 'on' :
data['php7'] = True
php7 = True
check_php_version= '7.0'
elif pargs.php7 == 'off':
data['php7'] = False
php7 = False
check_php_version = '5.6'
if pargs.pagespeed:
if pagespeed is old_pagespeed:
@ -1087,6 +1157,16 @@ class EESiteUpdateController(CementBaseController):
"site")
pargs.pagespeed = False
if pargs.php7:
if php7 is old_php7:
if php7 is False:
Log.info(self, "PHP 7.0 is already disabled for given "
"site")
elif php7 is True:
Log.info(self, "PHP 7.0 is already enabled for given "
"site")
pargs.php7 = False
#--letsencrypt=renew code goes here
if pargs.letsencrypt == "renew" and not pargs.all:
expiry_days = SSL.getExpirationDays(self,ee_domain)
@ -1177,7 +1257,35 @@ class EESiteUpdateController(CementBaseController):
data['pagespeed'] = False
pagespeed = False
if pargs.pagespeed=="on" or pargs.hhvm=="on" or pargs.letsencrypt=="on":
if data and (not pargs.php7):
if old_php7 is True:
data['php7'] = True
php7 = True
else:
data['php7'] = False
php7 = False
if pargs.pagespeed=="on" or pargs.hhvm=="on" or pargs.letsencrypt=="on" or pargs.php7=="on":
if pargs.php7 == "on":
if (not pargs.experimental):
Log.info(self, "PHP7.0 is experimental feature and it may not"
" work with all plugins of your site.\nYou can "
"disable it by passing --php7=off later.\nDo you wish"
" to enable PHP now for {0}?".format(ee_domain))
# Check prompt
check_prompt = input("Type \"y\" to continue [n]:")
if check_prompt != "Y" and check_prompt != "y":
Log.info(self, "Not using PHP 7.0 for site")
data['php7'] = False
php7 = False
else:
data['php7'] = True
php7 = True
else:
data['php7'] = True
php7 = True
if pargs.hhvm == "on":
if (not pargs.experimental):
Log.info(self, "HHVM is experimental feature and it may not"
@ -1259,7 +1367,7 @@ class EESiteUpdateController(CementBaseController):
data['basic'] = True
cache = 'basic'
if ((hhvm is old_hhvm) and (pagespeed is old_pagespeed) and
if ((hhvm is old_hhvm) and (pagespeed is old_pagespeed) and (php7 is old_php7) and
(stype == oldsitetype and cache == oldcachetype)):
return 1
@ -1372,7 +1480,7 @@ class EESiteUpdateController(CementBaseController):
"check issues with `nginx -t` command")
updateSiteInfo(self, ee_domain, stype=stype, cache=cache,
hhvm=hhvm, pagespeed=pagespeed,ssl=True if check_site.is_ssl else False)
hhvm=hhvm, pagespeed=pagespeed,ssl=True if check_site.is_ssl else False, php_version=check_php_version)
Log.info(self, "Successfully updated site"
" http://{0}".format(ee_domain))
@ -1590,10 +1698,10 @@ class EESiteUpdateController(CementBaseController):
db_user=data['ee_db_user'],
db_password=data['ee_db_pass'],
db_host=data['ee_db_host'], hhvm=hhvm,
pagespeed=pagespeed,ssl=True if check_site.is_ssl else False)
pagespeed=pagespeed,ssl=True if check_site.is_ssl else False,php_version=check_php_version)
else:
updateSiteInfo(self, ee_domain, stype=stype, cache=cache,
hhvm=hhvm, pagespeed=pagespeed,ssl=True if check_site.is_ssl else False)
hhvm=hhvm, pagespeed=pagespeed,ssl=True if check_site.is_ssl else False,php_version=check_php_version)
Log.info(self, "Successfully updated site"
" http://{0}".format(ee_domain))
return 0

191
ee/cli/plugins/site_functions.py

@ -54,6 +54,10 @@ def check_domain_exists(self, domain):
def setupdomain(self, data):
#for debug purpose
# for key, value in data.items() :
# print (key, value)
ee_domain_name = data['site_name']
ee_site_webroot = data['webroot'] if 'webroot' in data.keys() else ''
@ -68,9 +72,12 @@ def setupdomain(self, data):
ee_site_nginx_conf = open('/etc/nginx/sites-available/{0}'
.format(ee_domain_name), encoding='utf-8',
mode='w')
self.app.render((data), 'virtualconf.mustache',
out=ee_site_nginx_conf)
if not data['php7']:
self.app.render((data), 'virtualconf.mustache',
out=ee_site_nginx_conf)
else:
self.app.render((data), 'virtualconf-php7.mustache',
out=ee_site_nginx_conf)
ee_site_nginx_conf.close()
except IOError as e:
Log.debug(self, "{0}".format(e))
@ -250,7 +257,7 @@ def setupwordpress(self, data):
if 'wp-pass' in data.keys() and data['wp-pass']:
ee_wp_pass = data['wp-pass']
Log.info(self, "Downloading Wordpress \t\t", end='')
Log.info(self, "Downloading WordPress \t\t", end='')
EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
try:
if EEShellExec.cmd_exec(self, "wp --allow-root core"
@ -258,10 +265,10 @@ def setupwordpress(self, data):
pass
else:
Log.info(self, "[" + Log.ENDC + Log.FAIL + "Fail" + Log.OKBLUE + "]")
raise SiteError("download wordpress core failed")
raise SiteError("download WordPress core failed")
except CommandExecutionError as e:
Log.info(self, "[" + Log.ENDC + Log.FAIL + "Fail" + Log.OKBLUE + "]")
raise SiteError(self, "download wordpress core failed")
raise SiteError(self, "download WordPress core failed")
Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]")
@ -389,7 +396,7 @@ def setupwordpress(self, data):
ee_wp_user = input('Enter WordPress username: ')
except EOFError as e:
Log.debug(self, "{0}".format(e))
raise SiteError("input wordpress username failed")
raise SiteError("input WordPress username failed")
if not ee_wp_pass:
ee_wp_pass = ee_random
@ -400,7 +407,7 @@ def setupwordpress(self, data):
ee_wp_email = input('Enter WordPress email: ')
except EOFError as e:
Log.debug(self, "{0}".format(e))
raise SiteError("input wordpress username failed")
raise SiteError("input WordPress username failed")
try:
while not re.match(r"^[A-Za-z0-9\.\+_-]+@[A-Za-z0-9\._-]+\.[a-zA-Z]*$",
@ -434,9 +441,9 @@ def setupwordpress(self, data):
log=False):
pass
else:
raise SiteError("setup wordpress tables failed for single site")
raise SiteError("setup WordPress tables failed for single site")
except CommandExecutionError as e:
raise SiteError("setup wordpress tables failed for single site")
raise SiteError("setup WordPress tables failed for single site")
else:
Log.debug(self, "Creating tables for WordPress multisite")
Log.debug(self, "php {0} --allow-root "
@ -465,9 +472,9 @@ def setupwordpress(self, data):
log=False):
pass
else:
raise SiteError("setup wordpress tables failed for wp multi site")
raise SiteError("setup WordPress tables failed for wp multi site")
except CommandExecutionError as e:
raise SiteError("setup wordpress tables failed for wp multi site")
raise SiteError("setup WordPress tables failed for wp multi site")
Log.debug(self, "Updating WordPress permalink")
try:
@ -518,11 +525,11 @@ def setupwordpressnetwork(self, data):
pass
else:
Log.info(self, "[" + Log.ENDC + Log.FAIL + "Fail" + Log.OKBLUE + "]")
raise SiteError("setup wordpress network failed")
raise SiteError("setup WordPress network failed")
except CommandExecutionError as e:
Log.info(self, "[" + Log.ENDC + Log.FAIL + "Fail" + Log.OKBLUE + "]")
raise SiteError("setup wordpress network failed")
raise SiteError("setup WordPress network failed")
Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]")
@ -674,7 +681,7 @@ def site_package_check(self, stype):
stack = EEStackController()
stack.app = self.app
if stype in ['html', 'proxy', 'php', 'mysql', 'wp', 'wpsubdir',
'wpsubdomain']:
'wpsubdomain', 'php7']:
Log.debug(self, "Setting apt_packages variable for Nginx")
# Check if server has nginx-custom package
@ -699,10 +706,29 @@ def site_package_check(self, stype):
ee_nginx.write('fastcgi_param \tSCRIPT_FILENAME '
'\t$request_filename;\n')
if stype in ['php', 'mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
if self.app.pargs.php and self.app.pargs.php7:
Log.error(self,"INVALID OPTION: PHP 7.0 provided with PHP 5.0")
if not self.app.pargs.php7 and stype in ['php', 'mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
Log.debug(self, "Setting apt_packages variable for PHP")
if not EEAptGet.is_installed(self, 'php5-fpm'):
apt_packages = apt_packages + EEVariables.ee_php
if EEVariables.ee_platform_codename != 'trusty':
if not EEAptGet.is_installed(self, 'php5-fpm'):
apt_packages = apt_packages + EEVariables.ee_php
else:
if not EEAptGet.is_installed(self, 'php5.6-fpm'):
apt_packages = apt_packages + EEVariables.ee_php5_6 + EEVariables.ee_php_extra
if self.app.pargs.php7 and stype in [ 'mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
if EEVariables.ee_platform_codename == 'trusty':
Log.debug(self, "Setting apt_packages variable for PHP 7.0")
if not EEAptGet.is_installed(self, 'php7.0-fpm'):
apt_packages = apt_packages + EEVariables.ee_php7_0 + EEVariables.ee_php_extra
else:
Log.warn(self, "PHP 7.0 not available for your system.")
if not EEAptGet.is_installed(self, 'php5-fpm'):
Log.info(self, "Setting apt_packages variable for PHP 5.0")
Log.debug(self, "Setting apt_packages variable for PHP 5.0")
apt_packages = apt_packages + EEVariables.ee_php
if stype in ['mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
Log.debug(self, "Setting apt_packages variable for MySQL")
@ -821,6 +847,83 @@ def site_package_check(self, stype):
hhvm_file.write("upstream hhvm {\nserver 127.0.0.1:8000;\n"
"server 127.0.0.1:9000 backup;\n}\n")
if self.app.pargs.php7:
if EEVariables.ee_platform_codename != 'trusty':
Log.error(self,"PHP 7.0 is not supported in your Platform")
Log.debug(self, "Setting apt_packages variable for PHP 7.0")
if not EEAptGet.is_installed(self, 'php7.0-fpm'):
apt_packages = apt_packages + EEVariables.ee_php7_0 + EEVariables.ee_php_extra
if os.path.isdir("/etc/nginx/common") and (not
os.path.isfile("/etc/nginx/common/php7.conf")):
data = dict()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/locations-php7.conf')
ee_nginx = open('/etc/nginx/common/locations-php7.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'locations-php7.mustache',
out=ee_nginx)
ee_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/php7.conf')
ee_nginx = open('/etc/nginx/common/php7.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'php7.mustache',
out=ee_nginx)
ee_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/w3tc-php7.conf')
ee_nginx = open('/etc/nginx/common/w3tc-php7.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'w3tc-php7.mustache', out=ee_nginx)
ee_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/wpcommon-php7.conf')
ee_nginx = open('/etc/nginx/common/wpcommon-php7.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'wpcommon-php7.mustache',
out=ee_nginx)
ee_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/wpfc-php7.conf')
ee_nginx = open('/etc/nginx/common/wpfc-php7.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'wpfc-php7.mustache',
out=ee_nginx)
ee_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/wpsc-php7.conf')
ee_nginx = open('/etc/nginx/common/wpsc-php7.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'wpsc-php7.mustache',
out=ee_nginx)
ee_nginx.close()
if os.path.isfile("/etc/nginx/nginx.conf") and (not
os.path.isfile("/etc/nginx/common/redis-php7.conf")):
data = dict()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/redis-php7.conf')
ee_nginx = open('/etc/nginx/common/redis-php7.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'redis-php7.mustache',
out=ee_nginx)
ee_nginx.close()
if os.path.isfile("/etc/nginx/conf.d/upstream.conf"):
if not EEFileUtils.grep(self, "/etc/nginx/conf.d/upstream.conf",
"php7"):
with open("/etc/nginx/conf.d/upstream.conf", "a") as php_file:
php_file.write("upstream php7 {\nserver 127.0.0.1:9070;\n}\n"
"upstream debug7 {\nserver 127.0.0.1:9170;\n}\n")
# Check if Nginx is allready installed and Pagespeed config there or not
# If not then copy pagespeed config
if self.app.pargs.pagespeed:
@ -852,7 +955,7 @@ def updatewpuserpassword(self, ee_domain, ee_site_webroot):
is_wp = EEShellExec.cmd_exec(self, "wp --allow-root core"
" version")
except CommandExecutionError as e:
raise SiteError("is wordpress site? check command failed ")
raise SiteError("is WordPress site? check command failed ")
# Exit if ee_domain is not wordpress install
if not is_wp:
@ -989,7 +1092,7 @@ def detSitePar(opts):
cachelist = list()
for key, val in opts.items():
if val and key in ['html', 'php', 'mysql', 'wp',
'wpsubdir', 'wpsubdomain']:
'wpsubdir', 'wpsubdomain','php7']:
typelist.append(key)
elif val and key in ['wpfc', 'wpsc', 'w3tc', 'wpredis']:
cachelist.append(key)
@ -1003,12 +1106,24 @@ def detSitePar(opts):
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('php7','mysql','html') for x in typelist]:
sitetype = 'mysql'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('php','mysql') for x in typelist]:
sitetype = 'mysql'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('php7','mysql') for x in typelist]:
sitetype = 'mysql'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('html','mysql') for x in typelist]:
sitetype = 'mysql'
if not cachelist:
@ -1021,6 +1136,12 @@ def detSitePar(opts):
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('php7','html') for x in typelist]:
sitetype = 'php7'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wp','wpsubdir') for x in typelist]:
sitetype = 'wpsubdir'
if not cachelist:
@ -1033,14 +1154,31 @@ def detSitePar(opts):
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wp','php7') for x in typelist]:
sitetype = 'wp'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wpsubdir','php7') for x in typelist]:
sitetype = 'wpsubdir'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
elif False not in [x in ('wpsubdomain','php7') for x in typelist]:
sitetype = 'wpsubdomain'
if not cachelist:
cachetype = 'basic'
else:
cachetype = cachelist[0]
else:
raise RuntimeError("could not determine site and cache type")
else:
if not typelist and not cachelist:
sitetype = None
cachetype = None
elif (not typelist) and cachelist:
elif (not typelist or "php7" in typelist) and cachelist:
sitetype = 'wp'
cachetype = cachelist[0]
elif typelist and (not cachelist):
@ -1049,6 +1187,7 @@ def detSitePar(opts):
else:
sitetype = typelist[0]
cachetype = cachelist[0]
return (sitetype, cachetype)
@ -1207,7 +1346,7 @@ def setupLetsEncrypt(self, ee_domain_name):
ee_wp_email = input('Enter WordPress email: ')
except EOFError as e:
Log.debug(self, "{0}".format(e))
raise SiteError("input wordpress username failed")
raise SiteError("input WordPress username failed")
if not os.path.isdir("/opt/letsencrypt"):
cloneLetsEncrypt(self)
@ -1265,7 +1404,7 @@ def renewLetsEncrypt(self, ee_domain_name):
ee_wp_email = input('Enter email address: ')
except EOFError as e:
Log.debug(self, "{0}".format(e))
raise SiteError("Input wordpress email failed")
raise SiteError("Input WordPress email failed")
if not os.path.isdir("/opt/letsencrypt"):
cloneLetsEncrypt(self)
@ -1380,7 +1519,3 @@ def archivedCertificateHandle(self,domain,ee_wp_email):
.format(domain))
return ssl

9
ee/cli/plugins/sitedb.py

@ -12,14 +12,14 @@ import glob
def addNewSite(self, site, stype, cache, path,
enabled=True, ssl=False, fs='ext4', db='mysql',
db_name=None, db_user=None, db_password=None,
db_host='localhost', hhvm=0, pagespeed=0):
db_host='localhost', hhvm=0, pagespeed=0, php_version='5.5'):
"""
Add New Site record information into ee database.
"""
try:
newRec = SiteDB(site, stype, cache, path, enabled, ssl, fs, db,
db_name, db_user, db_password, db_host, hhvm,
pagespeed)
pagespeed, php_version)
db_session.add(newRec)
db_session.commit()
except Exception as e:
@ -42,7 +42,7 @@ def getSiteInfo(self, site):
def updateSiteInfo(self, site, stype='', cache='', webroot='',
enabled=True, ssl=False, fs='', db='', db_name=None,
db_user=None, db_password=None, db_host=None, hhvm=None,
pagespeed=None):
pagespeed=None, php_version=''):
"""updates site record in database"""
try:
q = SiteDB.query.filter(SiteDB.sitename == site).first()
@ -87,6 +87,9 @@ def updateSiteInfo(self, site, stype='', cache='', webroot='',
if (pagespeed is not None) and (q.is_pagespeed is not pagespeed):
q.is_pagespeed = pagespeed
if php_version and q.php_version != php_version:
q.php_version = php_version
try:
q.created_on = func.now()
db_session.commit()

542
ee/cli/plugins/stack.py

@ -62,6 +62,8 @@ class EEStackController(CementBaseController):
dict(help='Install Nginx mainline stack', action='store_true')),
(['--php'],
dict(help='Install PHP stack', action='store_true')),
(['--php7'],
dict(help='Install PHP 7.0 stack', action='store_true')),
(['--mysql'],
dict(help='Install MySQL stack', action='store_true')),
(['--hhvm'],
@ -178,16 +180,23 @@ class EEStackController(CementBaseController):
Log.debug(self, 'Adding ppa of Nginx-mainline')
EERepo.add_key(self, EEVariables.ee_nginx_key)
if set(EEVariables.ee_php).issubset(set(apt_packages)):
Log.info(self, "Adding repository for PHP, please wait...")
# Add repository for php
if EEVariables.ee_platform_distro == 'debian':
if EEVariables.ee_platform_codename != 'jessie':
Log.debug(self, 'Adding repo_url of php for debian')
EERepo.add(self, repo_url=EEVariables.ee_php_repo)
Log.debug(self, 'Adding Dotdeb/php GPG key')
EERepo.add_key(self, '89DF5277')
else:
if EEVariables.ee_platform_codename != 'trusty':
if set(EEVariables.ee_php).issubset(set(apt_packages)):
Log.info(self, "Adding repository for PHP, please wait...")
# Add repository for php
if EEVariables.ee_platform_distro == 'debian':
if EEVariables.ee_platform_codename != 'jessie':
Log.debug(self, 'Adding repo_url of php for debian')
EERepo.add(self, repo_url=EEVariables.ee_php_repo)
Log.debug(self, 'Adding Dotdeb/php GPG key')
EERepo.add_key(self, '89DF5277')
else:
Log.debug(self, 'Adding ppa for PHP')
EERepo.add(self, ppa=EEVariables.ee_php_repo)
else:
if set(EEVariables.ee_php7_0).issubset(set(apt_packages)) \
or set(EEVariables.ee_php5_6).issubset(set(apt_packages)):
Log.info(self, "Adding repository for PHP, please wait...")
Log.debug(self, 'Adding ppa for PHP')
EERepo.add(self, ppa=EEVariables.ee_php_repo)
@ -289,8 +298,8 @@ class EEStackController(CementBaseController):
self.app.render((data), 'fastcgi.mustache', out=ee_nginx)
ee_nginx.close()
data = dict(php="9000", debug="9001", hhvm="8000",
hhvmconf=False)
data = dict(php="9000", debug="9001", hhvm="8000",php7="9070",debug7="9170",
hhvmconf=False, php7conf= True if EEAptGet.is_installed(self,'php7.0-fpm') else False )
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/conf.d/upstream.conf')
ee_nginx = open('/etc/nginx/conf.d/upstream.conf',
@ -370,6 +379,65 @@ class EEStackController(CementBaseController):
out=ee_nginx)
ee_nginx.close()
#php7 conf
if EEVariables.ee_platform_codename == 'trusty' and (not
os.path.isfile("/etc/nginx/common/php7.conf")):
#data = dict()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/locations-php7.conf')
ee_nginx = open('/etc/nginx/common/locations-php7.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'locations-php7.mustache',
out=ee_nginx)
ee_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/php7.conf')
ee_nginx = open('/etc/nginx/common/php7.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'php7.mustache',
out=ee_nginx)
ee_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/w3tc-php7.conf')
ee_nginx = open('/etc/nginx/common/w3tc-php7.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'w3tc-php7.mustache', out=ee_nginx)
ee_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/wpcommon-php7.conf')
ee_nginx = open('/etc/nginx/common/wpcommon-php7.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'wpcommon-php7.mustache',
out=ee_nginx)
ee_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/wpfc-php7.conf')
ee_nginx = open('/etc/nginx/common/wpfc-php7.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'wpfc-php7.mustache',
out=ee_nginx)
ee_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/wpsc-php7.conf')
ee_nginx = open('/etc/nginx/common/wpsc-php7.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'wpsc-php7.mustache',
out=ee_nginx)
ee_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/redis-php7.conf')
ee_nginx = open('/etc/nginx/common/redis-php7.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'redis-php7.mustache',
out=ee_nginx)
ee_nginx.close()
# Nginx-Plus does not have nginx package structure like this
# So creating directories
if set(["nginx-plus"]).issubset(set(apt_packages)):
@ -385,8 +453,6 @@ class EEStackController(CementBaseController):
'/etc/nginx/sites-available')
os.makedirs('/etc/nginx/sites-enabled')
# 22222 port settings
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/sites-available/'
@ -543,6 +609,18 @@ class EEStackController(CementBaseController):
out=ee_nginx)
ee_nginx.close()
if EEVariables.ee_platform_codename == 'trusty':
if os.path.isfile("/etc/nginx/nginx.conf") and (not
os.path.isfile("/etc/nginx/common/redis-php7.conf")):
data = dict()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/redis-php7.conf')
ee_nginx = open('/etc/nginx/common/redis-php7.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'redis-php7.mustache',
out=ee_nginx)
ee_nginx.close()
if os.path.isfile("/etc/nginx/conf.d/upstream.conf"):
if not EEFileUtils.grep(self, "/etc/nginx/conf.d/"
"upstream.conf",
@ -560,6 +638,74 @@ class EEStackController(CementBaseController):
"log_format rt_cache_redis '$remote_addr $upstream_response_time $srcache_fetch_status [$time_local] '\n"
"'$http_host \"$request\" $status $body_bytes_sent '\n"
"'\"$http_referer\" \"$http_user_agent\"';\n")
#setup nginx common folder for php7
if self.app.pargs.php7:
if os.path.isdir("/etc/nginx/common") and (not
os.path.isfile("/etc/nginx/common/php7.conf")):
data = dict()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/locations-php7.conf')
ee_nginx = open('/etc/nginx/common/locations-php7.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'locations-php7.mustache',
out=ee_nginx)
ee_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/php7.conf')
ee_nginx = open('/etc/nginx/common/php7.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'php7.mustache',
out=ee_nginx)
ee_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/w3tc-php7.conf')
ee_nginx = open('/etc/nginx/common/w3tc-php7.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'w3tc-php7.mustache', out=ee_nginx)
ee_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/wpcommon-php7.conf')
ee_nginx = open('/etc/nginx/common/wpcommon-php7.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'wpcommon-php7.mustache',
out=ee_nginx)
ee_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/wpfc-php7.conf')
ee_nginx = open('/etc/nginx/common/wpfc-php7.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'wpfc-php7.mustache',
out=ee_nginx)
ee_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/wpsc-php7.conf')
ee_nginx = open('/etc/nginx/common/wpsc-php7.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'wpsc-php7.mustache',
out=ee_nginx)
ee_nginx.close()
if os.path.isdir("/etc/nginx/common") and (not os.path.isfile("/etc/nginx/common/redis-php7.conf")):
data = dict()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/redis-php7.conf')
ee_nginx = open('/etc/nginx/common/redis-php7.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'redis-php7.mustache',
out=ee_nginx)
ee_nginx.close()
if os.path.isfile("/etc/nginx/conf.d/upstream.conf"):
if not EEFileUtils.grep(self, "/etc/nginx/conf.d/upstream.conf",
"php7"):
with open("/etc/nginx/conf.d/upstream.conf", "a") as php_file:
php_file.write("upstream php7 {\nserver 127.0.0.1:9070;\n}\n"
"upstream debug7 {\nserver 127.0.0.1:9170;\n}\n")
# Set up pagespeed config
if self.app.pargs.pagespeed:
@ -703,7 +849,7 @@ class EEStackController(CementBaseController):
"'$http_host \"$request\" $status $body_bytes_sent '\n"
"'\"$http_referer\" \"$http_user_agent\"';\n")
if set(EEVariables.ee_php).issubset(set(apt_packages)):
if EEVariables.ee_platform_codename != 'trusty' and set(EEVariables.ee_php).issubset(set(apt_packages)):
# Create log directories
if not os.path.exists('/var/log/php5/'):
Log.debug(self, 'Creating directory /var/log/php5/')
@ -740,7 +886,9 @@ class EEStackController(CementBaseController):
"/etc/php5/fpm/php.ini")
config.write(configfile)
# Prase /etc/php5/fpm/php-fpm.conf
'''
#Code depreciated. Mustache version applied
# Parse /etc/php5/fpm/php-fpm.conf
config = configparser.ConfigParser()
Log.debug(self, "configuring php file"
"/etc/php5/fpm/php-fpm.conf")
@ -755,6 +903,17 @@ class EEStackController(CementBaseController):
Log.debug(self, "writting php5 configuration into "
"/etc/php5/fpm/php-fpm.conf")
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")
ee_php_fpm = open('/etc/php5/fpm/php-fpm.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'php-fpm.mustache', out=ee_php_fpm)
ee_php_fpm.close()
# Parse /etc/php5/fpm/pool.d/www.conf
config = configparser.ConfigParser()
@ -845,6 +1004,291 @@ class EEStackController(CementBaseController):
EEGit.add(self, ["/etc/php5"], msg="Adding PHP into Git")
EEService.restart_service(self, 'php5-fpm')
if EEVariables.ee_platform_codename == 'trusty' and set(EEVariables.ee_php5_6).issubset(set(apt_packages)):
# 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/')
# Parse etc/php/5.6/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')
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/5.6/fpm/php.ini',
encoding='utf-8', mode='w') as configfile:
Log.debug(self, "Writting php configuration into "
"/etc/php/5.6/fpm/php.ini")
config.write(configfile)
# Parse /etc/php/5.6/fpm/php-fpm.conf
'''
#Depreciated code. Mustache version Applied.
config = configparser.ConfigParser()
Log.debug(self, "configuring php file "
"/etc/php/5.6/fpm/php-fpm.conf")
config.read_file(codecs.open("/etc/php/5.6/fpm/php-fpm.conf",
"r", "utf8"))
config['global']['error_log'] = '/var/log/php/5.6/fpm.log'
config.remove_option('global', 'include')
config['global']['log_level'] = 'notice'
config['global']['include'] = '/etc/php/5.6/fpm/pool.d/*.conf'
with codecs.open('/etc/php/5.6/fpm/php-fpm.conf',
encoding='utf-8', mode='w') as configfile:
Log.debug(self, "writting php5 configuration into "
"/etc/php/5.6/fpm/php-fpm.conf")
config.write(configfile)
'''
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")
Log.debug(self, "writting php5 configuration into "
"/etc/php/5.6/fpm/php-fpm.conf")
ee_php_fpm = open('/etc/php/5.6/fpm/php-fpm.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'php-fpm.mustache', out=ee_php_fpm)
ee_php_fpm.close()
# Parse /etc/php/5.6/fpm/pool.d/www.conf
config = configparser.ConfigParser()
config.read_file(codecs.open('/etc/php/5.6/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/php/5.6/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")
config.write(configfile)
# Generate /etc/php/5.6/fpm/pool.d/debug.conf
EEFileUtils.copyfile(self, "/etc/php/5.6/fpm/pool.d/www.conf",
"/etc/php/5.6/fpm/pool.d/debug.conf")
EEFileUtils.searchreplace(self, "/etc/php/5.6/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['debug']['rlimit_core'] = 'unlimited'
config['debug']['slowlog'] = '/var/log/php/5.6/slow.log'
config['debug']['request_slowlog_timeout'] = '10s'
with open('/etc/php/5.6/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")
config.write(confifile)
with open("/etc/php/5.6/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 EEShellExec.cmd_exec(self, "grep -q \';zend_extension\' /etc/php/mods-available/xdebug.ini"):
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/php"], msg="Adding PHP into Git")
EEService.restart_service(self, 'php5.6-fpm')
#preconfiguration for php7.0
if EEVariables.ee_platform_codename == 'trusty' and 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
'''
#Depreciated code. Mustache version applied
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)
'''
data = dict(pid="/run/php/php7.0-fpm.pid", error_log="/var/log/php/7.0/fpm.log",
include="/etc/php/7.0/fpm/pool.d/*.conf")
Log.debug(self, "writting php 7.0 configuration into "
"/etc/php/7.0/fpm/php-fpm.conf")
ee_php_fpm = open('/etc/php/7.0/fpm/php-fpm.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'php-fpm.mustache', out=ee_php_fpm)
ee_php_fpm.close()
# 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
if not EEShellExec.cmd_exec(self, "grep -q \';zend_extension\' /etc/php/mods-available/xdebug.ini"):
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/php"], 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
# config = configparser.ConfigParser()
@ -1611,7 +2055,7 @@ class EEStackController(CementBaseController):
(not self.app.pargs.adminer) and (not self.app.pargs.utils) and
(not self.app.pargs.mailscanner) and (not self.app.pargs.all)
and (not self.app.pargs.redis) and (not self.app.pargs.nginxmainline) and
(not self.app.pargs.phpredisadmin)):
(not self.app.pargs.phpredisadmin) and (not self.app.pargs.php7)):
self.app.pargs.web = True
self.app.pargs.admin = True
@ -1756,12 +2200,31 @@ class EEStackController(CementBaseController):
if self.app.pargs.php:
Log.debug(self, "Setting apt_packages variable for PHP")
if not EEAptGet.is_installed(self, 'php5-fpm'):
apt_packages = apt_packages + EEVariables.ee_php
if not (EEAptGet.is_installed(self, 'php5-fpm') or EEAptGet.is_installed(self, 'php5.6-fpm')):
if EEVariables.ee_platform_codename == 'trusty':
apt_packages = apt_packages + EEVariables.ee_php5_6 + EEVariables.ee_php_extra
else:
apt_packages = apt_packages + EEVariables.ee_php
else:
Log.debug(self, "PHP already installed")
Log.info(self, "PHP already installed")
if self.app.pargs.php7:
if EEVariables.ee_platform_codename == 'trusty':
Log.debug(self, "Setting apt_packages variable for PHP 7.0")
if not EEAptGet.is_installed(self, 'php7.0-fpm') :
apt_packages = apt_packages + EEVariables.ee_php7_0 + EEVariables.ee_php_extra
if not EEAptGet.is_installed(self, 'php5.6-fpm'):
apt_packages = apt_packages + EEVariables.ee_php5_6 + EEVariables.ee_php_extra
else:
Log.debug(self, "PHP 7.0 already installed")
Log.info(self, "PHP 7.0 already installed")
else:
Log.debug(self, "PHP 7.0 Not Available for your Distribution")
Log.info(self, "PHP 7.0 Not Available for your Distribution")
if self.app.pargs.hhvm:
Log.debug(self, "Setting apt packages variable for HHVM")
if platform.architecture()[0] is '32bit':
@ -1944,7 +2407,7 @@ class EEStackController(CementBaseController):
# Default action for stack remove
if ((not self.app.pargs.web) and (not self.app.pargs.admin) and
(not self.app.pargs.mail) and (not self.app.pargs.nginx) and
(not self.app.pargs.php) and (not self.app.pargs.mysql) and
(not self.app.pargs.php) and (not self.app.pargs.php7) and (not self.app.pargs.mysql) and
(not self.app.pargs.postfix) and (not self.app.pargs.wpcli) and
(not self.app.pargs.phpmyadmin) and (not self.app.pargs.hhvm) and
(not self.app.pargs.adminer) and (not self.app.pargs.utils) and
@ -1958,6 +2421,8 @@ class EEStackController(CementBaseController):
self.app.pargs.web = True
self.app.pargs.admin = True
self.app.pargs.mail = True
if EEVariables.ee_platform_codename == 'trusty':
self.app.pargs.php7 = True
if self.app.pargs.web:
self.app.pargs.nginx = True
@ -2004,11 +2469,25 @@ class EEStackController(CementBaseController):
Log.error(self,"Cannot Remove! Nginx Mainline version not found.")
if self.app.pargs.php:
Log.debug(self, "Removing apt_packages variable of PHP")
apt_packages = apt_packages + EEVariables.ee_php
if EEVariables.ee_platform_codename == 'trusty':
apt_packages = apt_packages + EEVariables.ee_php5_6
if not EEAptGet.is_installed(self, 'php7.0-fpm'):
apt_packages = apt_packages + EEVariables.ee_php_extra
else:
apt_packages = apt_packages + EEVariables.ee_php
if self.app.pargs.php7:
if EEVariables.ee_platform_codename == 'trusty':
Log.debug(self, "Removing apt_packages variable of PHP 7.0")
apt_packages = apt_packages + EEVariables.ee_php7_0
if not EEAptGet.is_installed(self, 'php5.6-fpm'):
apt_packages = apt_packages + EEVariables.ee_php_extra
else:
Log.info(self,"PHP 7.0 not supported.")
if self.app.pargs.hhvm:
if EEAptGet.is_installed(self, 'hhvm'):
Log.debug(self, "Removing apt_packages varible of HHVM")
Log.debug(self, "Removing apt_packages variable of HHVM")
apt_packages = apt_packages + EEVariables.ee_hhvm
if self.app.pargs.redis:
Log.debug(self, "Remove apt_packages variable of Redis")
@ -2093,7 +2572,7 @@ class EEStackController(CementBaseController):
# Default action for stack purge
if ((not self.app.pargs.web) and (not self.app.pargs.admin) and
(not self.app.pargs.mail) and (not self.app.pargs.nginx) and
(not self.app.pargs.php) and (not self.app.pargs.mysql) and
(not self.app.pargs.php) and (not self.app.pargs.php7) and (not self.app.pargs.mysql) and
(not self.app.pargs.postfix) and (not self.app.pargs.wpcli) and
(not self.app.pargs.phpmyadmin) and (not self.app.pargs.hhvm) and
(not self.app.pargs.adminer) and (not self.app.pargs.utils) and
@ -2107,6 +2586,8 @@ class EEStackController(CementBaseController):
self.app.pargs.web = True
self.app.pargs.admin = True
self.app.pargs.mail = True
if EEVariables.ee_platform_codename == 'trusty':
self.app.pargs.php7 = True
if self.app.pargs.web:
self.app.pargs.nginx = True
@ -2153,7 +2634,20 @@ class EEStackController(CementBaseController):
Log.error(self,"Cannot Purge! Nginx Mainline version not found.")
if self.app.pargs.php:
Log.debug(self, "Purge apt_packages variable PHP")
apt_packages = apt_packages + EEVariables.ee_php
if EEVariables.ee_platform_codename == 'trusty':
apt_packages = apt_packages + EEVariables.ee_php5_6
if not EEAptGet.is_installed(self, 'php7.0-fpm'):
apt_packages = apt_packages + EEVariables.ee_php_extra
else:
apt_packages = apt_packages + EEVariables.ee_php
if self.app.pargs.php7:
if EEVariables.ee_platform_codename == 'trusty':
Log.debug(self, "Removing apt_packages variable of PHP 7.0")
apt_packages = apt_packages + EEVariables.ee_php7_0
if not EEAptGet.is_installed(self, 'php5.6-fpm'):
apt_packages = apt_packages + EEVariables.ee_php_extra
else:
Log.info(self,"PHP 7.0 not supported.")
if self.app.pargs.hhvm:
if EEAptGet.is_installed(self, 'hhvm'):
Log.debug(self, "Purge apt_packages varible of HHVM")

141
ee/cli/plugins/stack_services.py

@ -23,7 +23,7 @@ class EEStackStatusController(CementBaseController):
def start(self):
"""Start services"""
services = []
if not (self.app.pargs.nginx or self.app.pargs.php
if not (self.app.pargs.nginx or self.app.pargs.php or self.app.pargs.php7
or self.app.pargs.mysql or self.app.pargs.postfix
or self.app.pargs.hhvm or self.app.pargs.memcache
or self.app.pargs.dovecot or self.app.pargs.redis):
@ -39,10 +39,30 @@ class EEStackStatusController(CementBaseController):
Log.info(self, "Nginx is not installed")
if self.app.pargs.php:
if EEAptGet.is_installed(self, 'php5-fpm'):
services = services + ['php5-fpm']
if EEVariables.ee_platform_codename != 'trusty':
if EEAptGet.is_installed(self, 'php5-fpm'):
services = services + ['php5-fpm']
else:
Log.info(self, "PHP5-FPM is not installed")
else:
Log.info(self, "PHP5-FPM is not installed")
if EEAptGet.is_installed(self, 'php5.6-fpm'):
services = services + ['php5.6-fpm']
else:
Log.info(self, "PHP5.6-FPM is not installed")
if EEAptGet.is_installed(self, 'php7.0-fpm'):
services = services + ['php7.0-fpm']
else:
Log.info(self, "PHP7.0-FPM is not installed")
if self.app.pargs.php7:
if EEVariables.ee_platform_codename == 'trusty':
if EEAptGet.is_installed(self, 'php7.0-fpm'):
services = services + ['php7.0-fpm']
else:
Log.info(self, "PHP7.0-FPM is not installed")
else:
Log.info(self, "Your platform does not support PHP 7")
if self.app.pargs.mysql:
if ((EEVariables.ee_mysql_host is "localhost") or
@ -94,7 +114,7 @@ class EEStackStatusController(CementBaseController):
def stop(self):
"""Stop services"""
services = []
if not (self.app.pargs.nginx or self.app.pargs.php
if not (self.app.pargs.nginx or self.app.pargs.php or self.app.pargs.php7
or self.app.pargs.mysql or self.app.pargs.postfix
or self.app.pargs.hhvm or self.app.pargs.memcache
or self.app.pargs.dovecot or self.app.pargs.redis):
@ -110,10 +130,30 @@ class EEStackStatusController(CementBaseController):
Log.info(self, "Nginx is not installed")
if self.app.pargs.php:
if EEAptGet.is_installed(self, 'php5-fpm'):
services = services + ['php5-fpm']
if EEVariables.ee_platform_codename != 'trusty':
if EEAptGet.is_installed(self, 'php5-fpm'):
services = services + ['php5-fpm']
else:
Log.info(self, "PHP5-FPM is not installed")
else:
if EEAptGet.is_installed(self, 'php5.6-fpm'):
services = services + ['php5.6-fpm']
else:
Log.info(self, "PHP5.6-FPM is not installed")
if EEAptGet.is_installed(self, 'php7.0-fpm'):
services = services + ['php7.0-fpm']
else:
Log.info(self, "PHP7.0-FPM is not installed")
if self.app.pargs.php7:
if EEVariables.ee_platform_codename == 'trusty':
if EEAptGet.is_installed(self, 'php7.0-fpm'):
services = services + ['php7.0-fpm']
else:
Log.info(self, "PHP7.0-FPM is not installed")
else:
Log.info(self, "PHP5-FPM is not installed")
Log.info(self, "Your platform does not support PHP 7")
if self.app.pargs.mysql:
if ((EEVariables.ee_mysql_host is "localhost") or
@ -165,7 +205,7 @@ class EEStackStatusController(CementBaseController):
def restart(self):
"""Restart services"""
services = []
if not (self.app.pargs.nginx or self.app.pargs.php
if not (self.app.pargs.nginx or self.app.pargs.php or self.app.pargs.php7
or self.app.pargs.mysql or self.app.pargs.postfix
or self.app.pargs.hhvm or self.app.pargs.memcache
or self.app.pargs.dovecot or self.app.pargs.redis):
@ -181,10 +221,31 @@ class EEStackStatusController(CementBaseController):
Log.info(self, "Nginx is not installed")
if self.app.pargs.php:
if EEAptGet.is_installed(self, 'php5-fpm'):
services = services + ['php5-fpm']
if EEVariables.ee_platform_codename != 'trusty':
if EEAptGet.is_installed(self, 'php5-fpm'):
services = services + ['php5-fpm']
else:
Log.info(self, "PHP5-FPM is not installed")
else:
if EEAptGet.is_installed(self, 'php5.6-fpm'):
services = services + ['php5.6-fpm']
else:
Log.info(self, "PHP5.6-FPM is not installed")
if EEAptGet.is_installed(self, 'php7.0-fpm'):
services = services + ['php7.0-fpm']
else:
Log.info(self, "PHP7.0-FPM is not installed")
if self.app.pargs.php7:
if EEVariables.ee_platform_codename == 'trusty':
if EEAptGet.is_installed(self, 'php7.0-fpm'):
services = services + ['php7.0-fpm']
else:
Log.info(self, "PHP7.0-FPM is not installed")
else:
Log.info(self, "PHP5-FPM is not installed")
Log.info(self, "Your platform does not support PHP 7")
if self.app.pargs.mysql:
if ((EEVariables.ee_mysql_host is "localhost") or
@ -236,7 +297,7 @@ class EEStackStatusController(CementBaseController):
def status(self):
"""Status of services"""
services = []
if not (self.app.pargs.nginx or self.app.pargs.php
if not (self.app.pargs.nginx or self.app.pargs.php or self.app.pargs.php7
or self.app.pargs.mysql or self.app.pargs.postfix
or self.app.pargs.hhvm or self.app.pargs.memcache
or self.app.pargs.dovecot or self.app.pargs.redis):
@ -253,10 +314,30 @@ class EEStackStatusController(CementBaseController):
Log.info(self, "Nginx is not installed")
if self.app.pargs.php:
if EEAptGet.is_installed(self, 'php5-fpm'):
services = services + ['php5-fpm']
if EEVariables.ee_platform_codename != 'trusty':
if EEAptGet.is_installed(self, 'php5-fpm'):
services = services + ['php5-fpm']
else:
Log.info(self, "PHP5-FPM is not installed")
else:
if EEAptGet.is_installed(self, 'php5.6-fpm'):
services = services + ['php5.6-fpm']
else:
Log.info(self, "PHP5.6-FPM is not installed")
if EEAptGet.is_installed(self, 'php7.0-fpm'):
services = services + ['php7.0-fpm']
else:
Log.info(self, "PHP7.0-FPM is not installed")
if self.app.pargs.php7:
if EEVariables.ee_platform_codename == 'trusty':
if EEAptGet.is_installed(self, 'php7.0-fpm'):
services = services + ['php7.0-fpm']
else:
Log.info(self, "PHP7.0-FPM is not installed")
else:
Log.info(self, "PHP5-FPM is not installed")
Log.info(self, "Your platform does not support PHP 7")
if self.app.pargs.mysql:
if ((EEVariables.ee_mysql_host is "localhost") or
@ -308,7 +389,7 @@ class EEStackStatusController(CementBaseController):
def reload(self):
"""Reload service"""
services = []
if not (self.app.pargs.nginx or self.app.pargs.php
if not (self.app.pargs.nginx or self.app.pargs.php or self.app.pargs.php7
or self.app.pargs.mysql or self.app.pargs.postfix
or self.app.pargs.hhvm or self.app.pargs.memcache
or self.app.pargs.dovecot or self.app.pargs.redis):
@ -324,10 +405,30 @@ class EEStackStatusController(CementBaseController):
Log.info(self, "Nginx is not installed")
if self.app.pargs.php:
if EEAptGet.is_installed(self, 'php5-fpm'):
services = services + ['php5-fpm']
if EEVariables.ee_platform_codename != 'trusty':
if EEAptGet.is_installed(self, 'php5-fpm'):
services = services + ['php5-fpm']
else:
Log.info(self, "PHP5-FPM is not installed")
else:
if EEAptGet.is_installed(self, 'php5.6-fpm'):
services = services + ['php5.6-fpm']
else:
Log.info(self, "PHP5.6-FPM is not installed")
if EEAptGet.is_installed(self, 'php7.0-fpm'):
services = services + ['php7.0-fpm']
else:
Log.info(self, "PHP7.0-FPM is not installed")
if self.app.pargs.php7:
if EEVariables.ee_platform_codename == 'trusty':
if EEAptGet.is_installed(self, 'php7.0-fpm'):
services = services + ['php7.0-fpm']
else:
Log.info(self, "PHP7.0-FPM is not installed")
else:
Log.info(self, "PHP5-FPM is not installed")
Log.info(self, "Your platform does not support PHP 7")
if self.app.pargs.mysql:
if ((EEVariables.ee_mysql_host is "localhost") or

34
ee/cli/plugins/stack_upgrade.py

@ -67,7 +67,7 @@ class EEStackUpgradeController(CementBaseController):
Log.error(self, "Unable to find PHP 5.5")
Log.info(self, "During PHP update process non nginx-cached"
" parts of your site may remain down")
" parts of your site may remain down.")
# Check prompt
if (not self.app.pargs.no_prompt):
@ -86,7 +86,10 @@ class EEStackUpgradeController(CementBaseController):
Log.info(self, "Updating apt-cache, please wait...")
EEAptGet.update(self)
Log.info(self, "Installing packages, please wait ...")
EEAptGet.install(self, EEVariables.ee_php)
if EEVariables.ee_platform_codename == 'trusty':
EEAptGet.install(self, EEVariables.ee_php5_6 + EEVariables.ee_php_extra)
else:
EEAptGet.install(self, EEVariables.ee_php)
if EEVariables.ee_platform_distro == "debian":
EEShellExec.cmd_exec(self, "pecl install xdebug")
@ -159,10 +162,21 @@ class EEStackUpgradeController(CementBaseController):
Log.info(self, "Nginx Mainline is not already installed")
if self.app.pargs.php:
if EEAptGet.is_installed(self, 'php5-fpm'):
apt_packages = apt_packages + EEVariables.ee_php
if EEVariables.ee_platform_codename != 'trusty':
if EEAptGet.is_installed(self, 'php5-fpm'):
apt_packages = apt_packages + EEVariables.ee_php
else:
Log.info(self, "PHP is not installed")
else:
Log.info(self, "PHP is not installed")
if EEAptGet.is_installed(self, 'php5.6-fpm'):
apt_packages = apt_packages + EEVariables.ee_php5_6 + EEVariables.ee_php_extra
else:
Log.info(self, "PHP 5.6 is not installed")
if EEAptGet.is_installed(self, 'php7.0-fpm'):
apt_packages = apt_packages + EEVariables.ee_php7_0 + EEVariables.ee_php_extra
else:
Log.info(self, "PHP 7.0 is not installed")
if self.app.pargs.hhvm:
if EEAptGet.is_installed(self, 'hhvm'):
@ -226,8 +240,14 @@ class EEStackUpgradeController(CementBaseController):
if (set(EEVariables.ee_nginx).issubset(set(apt_packages)) or
set(EEVariables.ee_nginx_dev).issubset(set(apt_packages))):
EEService.restart_service(self, 'nginx')
if set(EEVariables.ee_php).issubset(set(apt_packages)):
EEService.restart_service(self, 'php5-fpm')
if EEVariables.ee_platform_codename != 'trusty':
if set(EEVariables.ee_php).issubset(set(apt_packages)):
EEService.restart_service(self, 'php5-fpm')
else:
if set(EEVariables.ee_php5_6).issubset(set(apt_packages)):
EEService.restart_service(self, 'php5.6-fpm')
if set(EEVariables.ee_php7_0).issubset(set(apt_packages)):
EEService.restart_service(self, 'php7.0-fpm')
if set(EEVariables.ee_hhvm).issubset(set(apt_packages)):
EEService.restart_service(self, 'hhvm')
if set(EEVariables.ee_postfix).issubset(set(apt_packages)):

68
ee/cli/templates/locations-php7.mustache

@ -0,0 +1,68 @@
# NGINX CONFIGURATION FOR COMMON LOCATION
# DO NOT MODIFY, ALL CHANGES LOST AFTER UPDATE EasyEngine (ee)
# Basic locations files
location = /favicon.ico {
access_log off;
log_not_found off;
expires max;
}
location = /robots.txt {
# Some WordPress plugin gererate robots.txt file
# Refer #340 issue
try_files $uri $uri/ /index.php?$args;
access_log off;
log_not_found off;
}
# Cache static files
location ~* \.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf|swf)$ {
add_header "Access-Control-Allow-Origin" "*";
access_log off;
log_not_found off;
expires max;
}
# Security settings for better privacy
# Deny hidden files
location ~ /\.well-known {
allow all;
}
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
# Deny backup extensions & log files
location ~* ^.+\.(bak|log|old|orig|original|php#|php~|php_bak|save|swo|swp|sql)$ {
deny all;
access_log off;
log_not_found off;
}
# Return 403 forbidden for readme.(txt|html) or license.(txt|html) or example.(txt|html)
if ($uri ~* "^.+(readme|license|example)\.(txt|html)$") {
return 403;
}
# Status pages
location /nginx_status {
stub_status on;
access_log off;
include common/acl.conf;
}
location ~ ^/(status|ping) {
include fastcgi_params;
fastcgi_pass php7;
include common/acl.conf;
}
# EasyEngine (ee) utilities
# phpMyAdmin settings
location /pma {
return 301 https://$host:22222/db/pma;
}
location /phpMyAdmin {
return 301 https://$host:22222/db/pma;
}
location /phpmyadmin {
return 301 https://$host:22222/db/pma;
}
# Adminer settings
location /adminer {
return 301 https://$host:22222/db/adminer;
}

5
ee/cli/templates/php-fpm.mustache

@ -0,0 +1,5 @@
[global]
pid = {{pid}}
error_log = {{error_log}}
log_level = notice
include = {{include}}

10
ee/cli/templates/php7.mustache

@ -0,0 +1,10 @@
# PHP NGINX CONFIGURATION
# DO NOT MODIFY, ALL CHANGES LOST AFTER UPDATE EasyEngine (ee)
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass php7;
}

56
ee/cli/templates/redis-php7.mustache

@ -0,0 +1,56 @@
# Redis NGINX CONFIGURATION
# DO NOT MODIFY, ALL CHANGES LOST AFTER UPDATE EasyEngine (ee)
set $skip_cache 0;
# POST requests and URL with a query string should always go to php
if ($request_method = POST) {
set $skip_cache 0;
}
if ($query_string != "") {
set $skip_cache 1;
}
# Don't cache URL containing the following segments
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|wp-.*.php|index.php|/feed/|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
set $skip_cache 1;
}
# Don't use the cache for logged in users or recent commenter
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
set $skip_cache 1;
}
# Use cached or actual file if they exists, Otherwise pass request to WordPress
location / {
try_files $uri $uri/ /index.php?$args;
}
location /redis-fetch {
internal ;
set $redis_key $args;
redis_pass redis;
}
location /redis-store {
internal ;
set_unescape_uri $key $arg_key ;
redis2_query set $key $echo_request_body;
redis2_query expire $key 14400;
redis2_pass redis;
}
location ~ \.php$ {
set $key "nginx-cache:$scheme$request_method$host$request_uri";
try_files $uri =404;
srcache_fetch_skip $skip_cache;
srcache_store_skip $skip_cache;
srcache_response_cache_control off;
set_escape_uri $escaped_key $key;
srcache_fetch GET /redis-fetch $key;
srcache_store PUT /redis-store key=$escaped_key;
more_set_headers 'X-SRCache-Fetch-Status $srcache_fetch_status';
more_set_headers 'X-SRCache-Store-Status $srcache_store_status';
include fastcgi_params;
fastcgi_pass php7;
}

1
ee/cli/templates/siteinfo.mustache

@ -1,6 +1,7 @@
Information about {{domain}}:
Nginx configuration {{type}} {{enable}}
{{#php_version}}PHP Version {{php_version}}{{/php_version}}
{{#pagespeed}}Pagespeed {{pagespeed}}{{/pagespeed}}
{{#hhvm}}HHVM {{hhvm}}{{/hhvm}}
{{#ssl}}SSL {{ssl}}{{/ssl}}

10
ee/cli/templates/upstream.mustache

@ -7,6 +7,16 @@ upstream debug {
# Debug Pool
server 127.0.0.1:{{debug}};
}
{{#php7conf}}
upstream php7 {
server 127.0.0.1:{{php7}};
}
upstream debug7 {
# Debug Pool
server 127.0.0.1:{{debug7}};
}
{{/php7conf}}
{{#hhvmconf}}
upstream hhvm {
# HHVM Pool

49
ee/cli/templates/virtualconf-php7.mustache

@ -0,0 +1,49 @@
server {
{{#multisite}}
# Uncomment the following line for domain mapping
# listen 80 default_server;
{{/multisite}}
server_name {{^vma}}{{^rc}}{{site_name}}{{/rc}}{{/vma}} {{#vma}}vma.*{{/vma}} {{#rc}}webmail.*{{/rc}} {{^vma}}{{^rc}}{{#multisite}}*{{/multisite}}{{^multisite}}www{{/multisite}}.{{site_name}}{{/rc}}{{/vma}};
{{#multisite}}
# Uncomment the following line for domain mapping
#server_name_in_redirect off;
{{/multisite}}
access_log /var/log/nginx/{{site_name}}.access.log {{^wpredis}}{{^static}}rt_cache{{/static}}{{/wpredis}}{{#wpredis}}rt_cache_redis{{/wpredis}};
error_log /var/log/nginx/{{site_name}}.error.log;
{{#proxy}}
add_header X-Proxy-Cache $upstream_cache_status;
location / {
proxy_pass http://{{host}}:{{port}};
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
{{/proxy}}
{{^proxy}}
{{^vma}}{{^rc}}root {{webroot}}/htdocs;{{/rc}}{{/vma}}
{{#vma}}root /var/www/22222/htdocs/vimbadmin/public;{{/vma}}
{{#rc}}root /var/www/roundcubemail/htdocs/;{{/rc}}
{{^proxy}}index {{^static}}index.php{{/static}} index.html index.htm;{{/proxy}}
{{#static}}
location / {
try_files $uri $uri/ =404;
}
{{/static}}
{{^static}}include {{^hhvm}}{{#basic}}common/php7.conf;{{/basic}}{{#w3tc}}common/w3tc-php7.conf;{{/w3tc}}{{#wpfc}}common/wpfc-php7.conf;{{/wpfc}} {{#wpsc}}common/wpsc-php7.conf;{{/wpsc}}{{#wpredis}}common/redis-php7.conf;{{/wpredis}} {{/hhvm}}{{#hhvm}}{{#basic}}common/php-hhvm.conf;{{/basic}}{{#w3tc}}common/w3tc-hhvm.conf;{{/w3tc}}{{#wpfc}}common/wpfc-hhvm.conf;{{/wpfc}} {{#wpsc}}common/wpsc-hhvm.conf;{{/wpsc}}{{#wpredis}}common/redis-hhvm.conf;{{/wpredis}} {{/hhvm}}
{{#wpsubdir}}include common/wpsubdir.conf;{{/wpsubdir}}{{/static}}
{{#wp}}include common/wpcommon-php7.conf;{{/wp}}
{{^proxy}}include common/locations-php7.conf;{{/proxy}}
{{^vma}}{{^rc}}include {{webroot}}/conf/nginx/*.conf;{{/rc}}{{/vma}}
{{/proxy}}
}

3
ee/cli/templates/virtualconf.mustache

@ -40,8 +40,7 @@ server {
}
{{/static}}
{{^static}}include {{^hhvm}}{{#basic}}common/php.conf;{{/basic}}{{#w3tc}}common/w3tc.conf;{{/w3tc}}{{#wpfc}}common/wpfc.conf;{{/wpfc}} {{#wpsc}}common/wpsc.conf;{{/wpsc}}{{#wpredis}}common/redis.conf;{{/wpredis}} {{/hhvm}}{{#hhvm}}{{#basic}}common/php-hhvm.conf;{{/basic}}{{#w3tc}}common/w3tc-hhvm.conf;{{/w3tc}}{{#wpfc}}common/wpfc-hhvm.conf;{{/wpfc}} {{#wpsc}}common/wpsc-hhvm.conf;{{/wpsc}}{{#wpredis}}common/redis-hhvm.conf;{{/wpredis}} {{/hhvm}}
{{#wpsubdir}}include common/wpsubdir.conf;{{/wpsubdir}}{{/static}}
{{^static}}include {{^hhvm}}{{#basic}}common/php.conf;{{/basic}}{{#w3tc}}common/w3tc.conf;{{/w3tc}}{{#wpfc}}common/wpfc.conf;{{/wpfc}} {{#wpsc}}common/wpsc.conf;{{/wpsc}}{{#wpredis}}common/redis.conf;{{/wpredis}} {{/hhvm}}{{#hhvm}}{{#basic}}common/php-hhvm.conf;{{/basic}}{{#w3tc}}common/w3tc-hhvm.conf;{{/w3tc}}{{#wpfc}}common/wpfc-hhvm.conf;{{/wpfc}} {{#wpsc}}common/wpsc-hhvm.conf;{{/wpsc}}{{#wpredis}}common/redis-hhvm.conf;{{/wpredis}} {{/hhvm}} {{#wpsubdir}}include common/wpsubdir.conf;{{/wpsubdir}}{{/static}}
{{#wp}}include common/wpcommon.conf;{{/wp}}
{{^proxy}}include common/locations.conf;{{/proxy}}
{{^vma}}{{^rc}}include {{webroot}}/conf/nginx/*.conf;{{/rc}}{{/vma}}

31
ee/cli/templates/w3tc-php7.mustache

@ -0,0 +1,31 @@
# W3TC NGINX CONFIGURATION
# DO NOT MODIFY, ALL CHANGES LOST AFTER UPDATE EasyEngine (ee)
set $cache_uri $request_uri;
# POST requests and URL with a query string should always go to php
if ($request_method = POST) {
set $cache_uri 'null cache';
}
if ($query_string != "") {
set $cache_uri 'null cache';
}
# Don't cache URL containing the following segments
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|wp-.*.php|index.php|/feed/|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
set $cache_uri 'null cache';
}
# Don't use the cache for logged in users or recent commenter
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") {
set $cache_uri 'null cache';
}
# Use cached or actual file if they exists, Otherwise pass request to WordPress
location / {
try_files /wp-content/cache/page_enhanced/${host}${cache_uri}_index.html $uri $uri/ /index.php?$args;
}
location ~ ^/wp-content/cache/minify/(.+\.(css|js))$ {
try_files $uri /wp-content/plugins/w3-total-cache/pub/minify.php?file=$1;
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass php7;
}

35
ee/cli/templates/wpcommon-php7.mustache

@ -0,0 +1,35 @@
# WordPress COMMON SETTINGS
# DO NOT MODIFY, ALL CHANGES LOST AFTER UPDATE EasyEngine (ee)
# Limit access to avoid brute force attack
location = /wp-login.php {
limit_req zone=one burst=1 nodelay;
include fastcgi_params;
fastcgi_pass php7;
}
# Disable wp-config.txt
location = /wp-config.txt {
deny all;
access_log off;
log_not_found off;
}
# Disallow php in upload folder
location /wp-content/uploads/ {
location ~ \.php$ {
#Prevent Direct Access Of PHP Files From Web Browsers
deny all;
}
}
# Yoast sitemap
location ~ ([^/]*)sitemap(.*)\.x(m|s)l$ {
rewrite ^/sitemap\.xml$ /sitemap_index.xml permanent;
rewrite ^/([a-z]+)?-?sitemap\.xsl$ /index.php?xsl=$1 last;
# Rules for yoast sitemap with wp|wpsubdir|wpsubdomain
rewrite ^.*/sitemap_index\.xml$ /index.php?sitemap=1 last;
rewrite ^.*/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
# Following lines are options. Needed for WordPress seo addons
rewrite ^/news_sitemap\.xml$ /index.php?sitemap=wpseo_news last;
rewrite ^/locations\.kml$ /index.php?sitemap=wpseo_local_kml last;
rewrite ^/geo_sitemap\.xml$ /index.php?sitemap=wpseo_local last;
rewrite ^/video-sitemap\.xsl$ /index.php?xsl=video last;
access_log off;
}

37
ee/cli/templates/wpfc-php7.mustache

@ -0,0 +1,37 @@
# WPFC NGINX CONFIGURATION
# DO NOT MODIFY, ALL CHANGES LOST AFTER UPDATE EasyEngine (ee)
set $skip_cache 0;
# POST requests and URL with a query string should always go to php
if ($request_method = POST) {
set $skip_cache 1;
}
if ($query_string != "") {
set $skip_cache 1;
}
# Don't cache URL containing the following segments
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|wp-.*.php|index.php|/feed/|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
set $skip_cache 1;
}
# Don't use the cache for logged in users or recent commenter
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
set $skip_cache 1;
}
# Use cached or actual file if they exists, Otherwise pass request to WordPress
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ ^/wp-content/cache/minify/(.+\.(css|js))$ {
try_files $uri /wp-content/plugins/w3-total-cache/pub/minify.php?file=$1;
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass php7;
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
fastcgi_cache WORDPRESS;
}
location ~ /purge(/.*) {
fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1";
access_log off;
}

31
ee/cli/templates/wpsc-php7.mustache

@ -0,0 +1,31 @@
# WPSC NGINX CONFIGURATION
# DO NOT MODIFY, ALL CHANGES LOST AFTER UPDATE EasyEngine (ee)
set $cache_uri $request_uri;
# POST requests and URL with a query string should always go to php
if ($request_method = POST) {
set $cache_uri 'null cache';
}
if ($query_string != "") {
set $cache_uri 'null cache';
}
# Don't cache URL containing the following segments
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|wp-.*.php|index.php|/feed/|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
set $cache_uri 'null cache';
}
# Don't use the cache for logged in users or recent commenter
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") {
set $cache_uri 'null cache';
}
# Use cached or actual file if they exists, Otherwise pass request to WordPress
location / {
# If we add index.php?$args its break WooCommerce like plugins
# Ref: #330
try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php;
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass php7;
# Following line is needed by WP Super Cache plugin
fastcgi_param SERVER_NAME $http_host;
}

4
ee/core/services.py

@ -112,10 +112,12 @@ class EEService():
.format(service_name))
def get_service_status(self, service_name):
try:
is_exist = subprocess.getstatusoutput('which {0}'
.format(service_name))
if is_exist[0] == 0:
if is_exist[0] == 0 or service_name in ['php7.0-fpm', 'php5.6-fpm']:
retcode = subprocess.getstatusoutput('service {0} status'
.format(service_name))
if retcode[0] == 0:

39
ee/core/variables.py

@ -12,7 +12,7 @@ class EEVariables():
"""Intialization of core variables"""
# EasyEngine version
ee_version = "3.4.1"
ee_version = "3.5.0"
# EasyEngine packages versions
@ -112,19 +112,35 @@ class EEVariables():
# PHP repo and packages
if ee_platform_distro == 'ubuntu':
ee_php_repo = "ppa:ondrej/php5-5.6"
elif ee_platform_codename == 'wheezy':
ee_php_repo = ("deb http://packages.dotdeb.org {codename}-php56 all"
if ee_platform_codename == 'precise':
ee_php_repo = "ppa:ondrej/php5-5.6"
ee_php = ["php5-fpm", "php5-curl", "php5-gd", "php5-imap",
"php5-mcrypt", "php5-common", "php5-readline",
"php5-mysql", "php5-cli", "php5-memcache", "php5-imagick",
"memcached", "graphviz", "php-pear"]
elif ee_platform_codename == 'trusty':
ee_php_repo = "ppa:ondrej/php"
ee_php5_6 = ["php5.6-fpm", "php5.6-curl", "php5.6-gd", "php5.6-imap",
"php5.6-mcrypt", "php5.6-readline", "php5.6-common",
"php5.6-mysql", "php5.6-cli"]
ee_php7_0 = ["php7.0-fpm", "php7.0-curl", "php7.0-gd", "php7.0-imap",
"php7.0-mcrypt", "php7.0-readline", "php7.0-common",
"php7.0-mysql", "php7.0-cli"]
ee_php_extra = ["php-memcached", "php-imagick", "memcached",
"graphviz", "php-pear", "php-xdebug", "php-msgpack"]
elif ee_platform_distro == 'debian':
if ee_platform_codename == 'wheezy':
ee_php_repo = ("deb http://packages.dotdeb.org {codename}-php56 all"
.format(codename=ee_platform_codename))
ee_php = ["php5-fpm", "php5-curl", "php5-gd", "php5-imap",
"php5-mcrypt", "php5-common", "php5-readline",
"php5-mysql", "php5-cli", "php5-memcache", "php5-imagick",
"memcached", "graphviz", "php-pear"]
ee_php = ["php5-fpm", "php5-curl", "php5-gd", "php5-imap",
"php5-mcrypt", "php5-common", "php5-readline",
"php5-mysql", "php5-cli", "php5-memcache", "php5-imagick",
"memcached", "graphviz", "php-pear"]
if ee_platform_codename == 'wheezy':
ee_php = ee_php + ["php5-dev"]
if ee_platform_distro == 'ubuntu' or ee_platform_codename == 'jessie':
if ee_platform_codename == 'precise' or ee_platform_codename == 'jessie':
ee_php = ee_php + ["php5-xdebug"]
# MySQL repo and packages
@ -180,7 +196,10 @@ class EEVariables():
ee_redis_repo = ("deb http://packages.dotdeb.org {codename} all"
.format(codename=ee_platform_codename))
ee_redis = ['redis-server', 'php5-redis']
if ee_platform_codename == 'trusty':
ee_redis = ['redis-server', 'php-redis']
else:
ee_redis = ['redis-server', 'php5-redis']
# Repo path
ee_repo_file = "ee-repo.list"

59
install

@ -48,7 +48,7 @@ fi
# Define variables for later use
ee_branch=$1
readonly ee_version_old="2.2.3"
readonly ee_version_new="3.4.1"
readonly ee_version_new="3.5.0"
readonly ee_log_dir=/var/log/ee/
readonly ee_install_log=/var/log/ee/install.log
readonly ee_linux_distro=$(lsb_release -i | awk '{print $3}')
@ -121,7 +121,8 @@ function ee_sync_db()
db_password VARCHAR,
db_host VARCHAR,
is_hhvm INT INT DEFAULT '0',
is_pagespeed INT INT DEFAULT '0'
is_pagespeed INT INT DEFAULT '0',
php_version VARCHAR
);" | sqlite3 /var/lib/ee/ee.db
# Check site is enable/live or disable
@ -206,6 +207,7 @@ function ee_sync_db()
done
else
ee_php_version=$(php -v | head -n1 | cut -d' ' -f2 |cut -c1-3)
ee_lib_echo "Updating EasyEngine Database"
echo "ALTER TABLE sites ADD COLUMN db_name varchar;" | sqlite3 /var/lib/ee/ee.db
echo "ALTER TABLE sites ADD COLUMN db_user varchar; " | sqlite3 /var/lib/ee/ee.db
@ -213,6 +215,7 @@ function ee_sync_db()
echo "ALTER TABLE sites ADD COLUMN db_host varchar;" | sqlite3 /var/lib/ee/ee.db
echo "ALTER TABLE sites ADD COLUMN is_hhvm INT DEFAULT '0';" | sqlite3 /var/lib/ee/ee.db
echo "ALTER TABLE sites ADD COLUMN is_pagespeed INT DEFAULT '0';" | sqlite3 /var/lib/ee/ee.db
echo "ALTER TABLE sites ADD COLUMN php_version varchar DEFAULT \"$ee_php_version\";" | sqlite3 /var/lib/ee/ee.db
fi
}
@ -293,6 +296,39 @@ function ee_update()
ln -s /usr/local/bin/ee /usr/local/sbin/ee || ee_lib_error "Unable to create softlink to old EasyEngine, exit status " $?
}
function ee_upgrade_php(){
#Upgrade PHP5.6 to a new repo supporting PHP 7.0
if [ "$ee_distro_version" == "trusty" ]; then
if [ -f /etc/apt/sources.list.d/ondrej-php5-5_6-trusty.list ]; then
# add-apt-repository -y --remove 'ppa:ondrej/php5-5.6'
add-apt-repository -y 'ppa:ondrej/php'
ee_lib_echo "Upgrading required packages, please wait..."
apt-get update &>> /dev/null
apt-get -y install php5.6-fpm php5.6-curl php5.6-gd php5.6-imap php5.6-mcrypt php5.6-readline php5.6-mysql php5.6-cli php5.6-common php-memcached php-imagick memcached graphviz php-pear php-xdebug php-msgpack || ee_lib_error "Unable to install PHP 5.6 packages, exit status " 1
if [ -e /etc/php5/fpm/pool.d/www.conf -a -e /etc/php5/fpm/pool.d/debug.conf -a -e /etc/php5/fpm/php.ini -a -e /etc/php5/fpm/php-fpm.conf ]; then
cp -f /etc/php5/fpm/pool.d/www.conf /etc/php/5.6/fpm/pool.d/www.conf &>> /dev/null
cp -f /etc/php5/fpm/pool.d/debug.conf /etc/php/5.6/fpm/pool.d/debug.conf &>> /dev/null
cp -f /etc/php5/fpm/php.ini /etc/php/5.6/fpm/php.ini &>> /dev/null
cp -f /etc/php5/fpm/php-fpm.conf /etc/php/5.6/fpm/php-fpm.conf &>> /dev/null
else
echo "Some files are missing." || ee_lib_error "Unable to configure PHP5.6 packages, exit status " 1
fi
sed -i "s/pid.*/pid = \/run\/php\/php5.6-fpm.pid/" /etc/php/5.6/fpm/php-fpm.conf && \
sed -i "s/error_log.*/error_log = \/var\/log\/php\/5.6\/fpm.log/" /etc/php/5.6/fpm/php-fpm.conf && \
sed -i "s/log_level.*/log_level = notice/" /etc/php/5.6/fpm/php-fpm.conf && \
sed -i "s/include.*/include = \/etc\/php\/5.6\/fpm\/pool.d\/*.conf/" /etc/php/5.6/fpm/php-fpm.conf && \
sed -i "s/slowlog =.*/slowlog = \/var\/log\/php\/5.6\/slow.log/" /etc/php/5.6/fpm/pool.d/debug.conf || ee_lib_error "Unable to update configuration, exit status " $?
mkdir -p /var/log/php/5.6/
touch /var/log/php/5.6/slow.log /var/log/php/5.6/fpm.log
service php5-fpm stop &>> /dev/null
service php5.6-fpm restart &>> /dev/null
rm -f /etc/apt/sources.list.d/ondrej-php5-5_6-trusty.list &>> /dev/null
apt-get remove -y php5-fpm php5-curl php5-gd php5-imap php5-mcrypt php5-common php5-readline php5-mysql php5-cli php5-memcache php5-imagick memcached graphviz php-pear
fi
fi
}
function ee_update_latest()
{
#Move ~/.my.cnf to /etc/mysql/conf.d/my.cnf
@ -321,6 +357,7 @@ function ee_update_latest()
fi
fi
if [ -f /etc/nginx/nginx.conf ]; then
ee_lib_echo "Updating Nginx configuration, please wait..."
# From version 3.1.10 we are using Suse builder for repository
@ -557,6 +594,16 @@ function ee_git_init()
git add -A .
git commit -am "Installed/Updated to EasyEngine 3.x" &>> /dev/null
#PHP under git version control
if [ -d /etc/php ];then
cd /etc/php
if [ ! -d /etc/php/.git ]; then
git init &>> /dev/null
fi
git add -A .
git commit -am "Updated PHP" > /dev/null
fi
}
# Update EasyEngine
@ -577,6 +624,7 @@ if [ -f /usr/local/sbin/easyengine ]; then
ee_install_dep | tee -ai $ee_install_log
ee_sync_db 2&>>1 $EE_INSTALL_LOG
secure_ee_db | tee -ai $EE_INSTALL_LOG
ee_upgrade_php | tee -ai $ee_install_log
ee_install | tee -ai $ee_install_log
ee_update | tee -ai $ee_install_log
ee_update_latest | tee -ai $ee_install_log
@ -598,11 +646,16 @@ else
ee_install_dep | tee -ai $ee_install_log
ee_sync_db 2&>>1 $EE_INSTALL_LOG
secure_ee_db | tee -ai $EE_INSTALL_LOG
ee_upgrade_php | tee -ai $ee_install_log
ee_install | tee -ai $ee_install_log
ee_update_latest | tee -ai $ee_install_log
ee_git_init | tee -ai $ee_install_log
service nginx reload &>> /dev/null
service php5-fpm restart &>> /dev/null
if [ "$ee_distro_version" == "trusty" ]; then
service php5.6-fpm restart &>> /dev/null
else
service php5-fpm restart &>> /dev/null
fi
ee_update_wp_cli | tee -ai $ee_install_log
else
ee_lib_error "Not updating EasyEngine to $ee_version_new, exit status = " 1

2
setup.py

@ -58,7 +58,7 @@ if not os.path.isfile('/root/.gitconfig'):
shutil.copy2(os.path.expanduser("~")+'/.gitconfig', '/root/.gitconfig')
setup(name='ee',
version='3.4.1',
version='3.5.0',
description=long_description,
long_description=long_description,
classifiers=[],

Loading…
Cancel
Save