diff --git a/interface/web/sites/web_vhost_domain_edit.php b/interface/web/sites/web_vhost_domain_edit.php
index cc476a2276f8c87206859aa9bdb4717e30be4df6..2ae5e4f45fe4d810ba45957ea3554a56d2b0b95e 100644
--- a/interface/web/sites/web_vhost_domain_edit.php
+++ b/interface/web/sites/web_vhost_domain_edit.php
@@ -244,17 +244,17 @@ class page_action extends tform_actions {
 
 			if($this->_vhostdomain_type == 'domain') {
 				if($this->dataRecord['php'] == 'php-fpm' || ($this->dataRecord['php'] == 'hhvm' && $server_type == 'nginx')){
-					$php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = ? AND (client_id = 0 OR client_id=?) AND active = 'y'", ($this->id > 0 ? $this->dataRecord['server_id'] : $client['default_webserver']), $_SESSION['s']['user']['client_id']);
+					$php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = ? AND (client_id = 0 OR client_id=?) AND active = 'y' ORDER BY server_php.name", ($this->id > 0 ? $this->dataRecord['server_id'] : $client['default_webserver']), $_SESSION['s']['user']['client_id']);
 				}
 				if($this->dataRecord['php'] == 'fast-cgi'){
-					$php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = ? AND (client_id = 0 OR client_id=?) AND active = 'y'", ($this->id > 0 ? $this->dataRecord['server_id'] : $client['default_webserver']), $_SESSION['s']['user']['client_id']);
+					$php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = ? AND (client_id = 0 OR client_id=?) AND active = 'y' ORDER BY server_php.name", ($this->id > 0 ? $this->dataRecord['server_id'] : $client['default_webserver']), $_SESSION['s']['user']['client_id']);
 				}
 			} else {
 				if($this->dataRecord['php'] == 'php-fpm' || ($this->dataRecord['php'] == 'hhvm' && $server_type == 'nginx')){
-					$php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = ? AND (client_id = 0 OR client_id=?) AND active = 'y'", $parent_domain['server_id'], $_SESSION['s']['user']['client_id']);
+					$php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = ? AND (client_id = 0 OR client_id=?) AND active = 'y' ORDER BY server_php.name", $parent_domain['server_id'], $_SESSION['s']['user']['client_id']);
 				}
 				if($this->dataRecord['php'] == 'fast-cgi'){
-					$php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = ? AND (client_id = 0 OR client_id=?) AND active = 'y'", $parent_domain['server_id'], $_SESSION['s']['user']['client_id']);
+					$php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = ? AND (client_id = 0 OR client_id=?) AND active = 'y' ORDER BY server_php.name", $parent_domain['server_id'], $_SESSION['s']['user']['client_id']);
 				}
 			}
 			if (empty($web_config['php_default_hide']) || 'n' === $web_config['php_default_hide']) {
diff --git a/server/lib/classes/cron.d/150-goaccess.inc.php b/server/lib/classes/cron.d/150-goaccess.inc.php
index 5c915e579a59d348cb1b6ffd646c661d18419ec6..295f15301116c5229bd41a90e7c8ac4156361876 100644
--- a/server/lib/classes/cron.d/150-goaccess.inc.php
+++ b/server/lib/classes/cron.d/150-goaccess.inc.php
@@ -61,185 +61,186 @@ class cronjob_goaccess extends cronjob {
 
 		$web_config = $app->getconf->get_server_config($conf['server_id'], 'web');
 
-                $goaccess_conf_locs = array('/etc/goaccess.conf', '/etc/goaccess/goaccess.conf');
-                $count = 0;
-
-                foreach($goaccess_conf_locs as $goa_loc) {
-                        if(is_file($goa_loc) && (filesize($goa_loc) > 0)) {
-                                $goaccess_conf_main = $goa_loc;
-                                break;
-                        } else {
-                                $count++;
-                                if($count == 2) {
-                                        $app->log("No GoAccess base config found. Make sure that GoAccess is installed and that the goaccess.conf does exist in /etc or /etc/goaccess", LOGLEVEL_ERROR);
-                                }
-                        }
-                }
-
-
-                /* Check if goaccess binary is in path/installed */
-		if($app->system->is_installed('goaccess')) {
-
-			foreach($records as $rec) {
-				$yesterday = date('Ymd', strtotime("-1 day", time()));
-
-				$log_folder = 'log';
-
-				if($rec['type'] == 'vhostsubdomain' || $rec['type'] == 'vhostalias') {
-					$tmp = $app->db->queryOneRecord('SELECT `domain` FROM web_domain WHERE domain_id = ?', $rec['parent_domain_id']);
-					$subdomain_host = preg_replace('/^(.*)\.' . preg_quote($tmp['domain'], '/') . '$/', '$1', $rec['domain']);
-					if($subdomain_host == '') $subdomain_host = 'web'.$rec['domain_id'];
-					$log_folder .= '/' . $subdomain_host;
-					unset($tmp);
-				}
-
-				$logfile = $rec['document_root'].'/' . $log_folder . '/'.$yesterday.'-access.log';
+		if(is_array($records) && !empty($records)) {
 
-				if(!@is_file($logfile)) {
-					$logfile = $rec['document_root'].'/' . $log_folder . '/'.$yesterday.'-access.log.gz';
-					if(!@is_file($logfile)) {
-						continue;
-					}
-				}
+	                /* Check if goaccess binary is in path/installed */
+			if($app->system->is_installed('goaccess')) {
 
-				$web_folder = (($rec['type'] == 'vhostsubdomain' || $rec['type'] == 'vhostalias') ? $rec['web_folder'] : 'web');
-				$domain = $rec['domain'];
-				$statsdir = $rec['document_root'].'/'.$web_folder.'/stats';
-				$goaccess_conf = $rec['document_root'].'/log/goaccess.conf';
+		                $goaccess_conf_locs = array('/etc/goaccess.conf', '/etc/goaccess/goaccess.conf');
+		                $count = 0;
 
-				/*
-				 In case that you use a different log format, you should use a custom goaccess.conf which you'll have to put into /usr/local/ispconfig/server/conf-custom/.
-				 By default the originally, with GoAccess shipped goaccess.conf from /etc/ or /etc/goaccess will be used along with the log-format value COMBINED. 
-				*/
+		                foreach($goaccess_conf_locs as $goa_loc) {
+		                        if(is_file($goa_loc) && (filesize($goa_loc) > 0)) {
+		                                $goaccess_conf_main = $goa_loc;
+		                                break;
+		                        } else {
+		                                $count++;
+	        	                        if($count == 2) {
+		                                        $app->log("No GoAccess base config found. Make sure that GoAccess is installed and that the goaccess.conf does exist in /etc or /etc/goaccess", LOGLEVEL_ERROR);
+		                                }
+		                        }
+		                }
 
-				if(file_exists("/usr/local/ispconfig/server/conf-custom/goaccess.conf.master") && (!file_exists($goaccess_conf))) {
-					$app->system->copy("/usr/local/ispconfig/server/conf-custom/goaccess.conf.master", $goaccess_conf);
-				} elseif(!file_exists($goaccess_conf)) {
-					/*
-					 By default the goaccess.conf should get copied by the webserver plugin but in case it wasn't, or it got deleted by accident we gonna copy it again to the destination dir.
-					 Also there was no /usr/local/ispconfig/server/conf-custom/goaccess.conf.master, so we gonna use /etc/goaccess.conf or /etc/goaccess/goaccess.conf as the base conf.
-					*/
 
-					$app->system->copy($goaccess_conf_main, $goaccess_conf);
-					$content = $app->system->file_get_contents($goaccess_conf, true);
-					$content = preg_replace('/^(#)?log-format COMBINED/m', "log-format COMBINED", $content);
-					$app->system->file_put_contents($goaccess_conf, $content, true);
-					unset($content);
-				}
+				foreach($records as $rec) {
+					$yesterday = date('Ymd', strtotime("-1 day", time()));
+	
+					$log_folder = 'log';
+	
+					if($rec['type'] == 'vhostsubdomain' || $rec['type'] == 'vhostalias') {
+						$tmp = $app->db->queryOneRecord('SELECT `domain` FROM web_domain WHERE domain_id = ?', $rec['parent_domain_id']);
+						$subdomain_host = preg_replace('/^(.*)\.' . preg_quote($tmp['domain'], '/') . '$/', '$1', $rec['domain']);
+						if($subdomain_host == '') $subdomain_host = 'web'.$rec['domain_id'];
+						$log_folder .= '/' . $subdomain_host;
+						unset($tmp);
+					}
 
-				/* Update the primary domain name in the title, it could occasionally change */
-				if(is_file($goaccess_conf) && (filesize($goaccess_conf) > 0)) {
-					$content = $app->system->file_get_contents($goaccess_conf, true);
-					$content = preg_replace('/^(#)?html-report-title(.*)/m', "html-report-title $domain", $content);
-					$app->system->file_put_contents($goaccess_conf, $content, true);
-					unset($content);
-				}
+					$logfile = $rec['document_root'].'/' . $log_folder . '/'.$yesterday.'-access.log';
 
-                                $username = $rec['system_user'];
-                                $groupname = $rec['system_group'];
-                                $docroot = $rec['document_root'];
+					if(!@is_file($logfile)) {
+						$logfile = $rec['document_root'].'/' . $log_folder . '/'.$yesterday.'-access.log.gz';
+						if(!@is_file($logfile)) {
+							continue;
+						}
+					}
 
-				if(!@is_dir($statsdir)) $app->system->mkdirpath($statsdir, 0755, $username, $groupname);
+					$web_folder = (($rec['type'] == 'vhostsubdomain' || $rec['type'] == 'vhostalias') ? $rec['web_folder'] : 'web');
+					$domain = $rec['domain'];
+					$statsdir = $rec['document_root'].'/'.$web_folder.'/stats';
+					$goaccess_conf = $rec['document_root'].'/log/goaccess.conf';
 
-				$goa_db_dir = $docroot.'/'.$web_folder.'/stats/.db/';
-				$output_html = $docroot.'/'.$web_folder.'/stats/goaindex.html';
-	                        if(!@is_dir($goa_db_dir)) $app->system->mkdirpath($goa_db_dir);
-	
-	                        if(is_link('/var/log/ispconfig/httpd/'.$domain.'/yesterday-access.log')) $app->system->unlink('/var/log/ispconfig/httpd/'.$domain.'/yesterday-access.log');
-				$app->system->create_relative_link($logfile, '/var/log/ispconfig/httpd/'.$domain.'/yesterday-access.log');
+					/*
+					 In case that you use a different log format, you should use a custom goaccess.conf which you'll have to put into /usr/local/ispconfig/server/conf-custom/.
+					 By default the originally, with GoAccess shipped goaccess.conf from /etc/ or /etc/goaccess will be used along with the log-format value COMBINED. 
+					*/
 
-				$app->system->exec_safe('chown -R ?:? ?', $username, $groupname, $statsdir);
+					if(file_exists("/usr/local/ispconfig/server/conf-custom/goaccess.conf.master") && (!file_exists($goaccess_conf))) {
+						$app->system->copy("/usr/local/ispconfig/server/conf-custom/goaccess.conf.master", $goaccess_conf);
+					} elseif(!file_exists($goaccess_conf)) {
 
-				$goamonth = date("n");
-				$goayear = date("Y");
+						/*
+						 By default the goaccess.conf should get copied by the webserver plugin but in case it wasn't, or it got deleted by accident we gonna copy it again to the destination dir.
+						 Also there was no /usr/local/ispconfig/server/conf-custom/goaccess.conf.master, so we gonna use /etc/goaccess.conf or /etc/goaccess/goaccess.conf as the base conf.
+						*/
 
-				if (date("d") == 1) {
-					$goamonth = date("m")-1;
-					if (date("m") == 1) {
-						$goayear = date("Y")-1;
-						$goamonth = "12";
+						$app->system->copy($goaccess_conf_main, $goaccess_conf);
+						$content = $app->system->file_get_contents($goaccess_conf, true);
+						$content = preg_replace('/^(#)?log-format COMBINED/m', "log-format COMBINED", $content);
+						$app->system->file_put_contents($goaccess_conf, $content, true);
+						unset($content);
 					}
-				}
 
-				if (date("d") == 2) {
-					$goamonth = date("m")-1;
-					if (date("m") == 1) {
-						$goayear = date("Y")-1;
-						$goamonth = "12";
+					/* Update the primary domain name in the title, it could occasionally change */
+					if(is_file($goaccess_conf) && (filesize($goaccess_conf) > 0)) {
+						$content = $app->system->file_get_contents($goaccess_conf, true);
+						$content = preg_replace('/^(#)?html-report-title(.*)/m', "html-report-title $domain", $content);
+						$app->system->file_put_contents($goaccess_conf, $content, true);
+						unset($content);
 					}
 
-					$statsdirold = $statsdir."/".$goayear."-".$goamonth."/";
+	                                $username = $rec['system_user'];
+	                                $groupname = $rec['system_group'];
+	                                $docroot = $rec['document_root'];
+
+					if(!@is_dir($statsdir)) $app->system->mkdirpath($statsdir, 0755, $username, $groupname);
 
-					if(!is_dir($statsdirold)) {
-						 $app->system->mkdirpath($statsdirold, 0755, $username, $groupname);
+					$goa_db_dir = $docroot.'/'.$web_folder.'/stats/.db/';
+					$output_html = $docroot.'/'.$web_folder.'/stats/goaindex.html';
+		                        if(!@is_dir($goa_db_dir)) $app->system->mkdirpath($goa_db_dir);
+	
+		                        if(is_link('/var/log/ispconfig/httpd/'.$domain.'/yesterday-access.log')) $app->system->unlink('/var/log/ispconfig/httpd/'.$domain.'/yesterday-access.log');
+					$app->system->create_relative_link($logfile, '/var/log/ispconfig/httpd/'.$domain.'/yesterday-access.log');
+
+					$app->system->exec_safe('chown -R ?:? ?', $username, $groupname, $statsdir);
+	
+					$goamonth = date("n");
+					$goayear = date("Y");
+
+					if (date("d") == 1) {
+						$goamonth = date("m")-1;
+						if (date("m") == 1) {
+							$goayear = date("Y")-1;
+							$goamonth = "12";
+						}
 					}
 
-					// don't rotate db files per month
-					//rename($goa_db_dir, $statsdirold.'db');
-					//mkdir($goa_db_dir);
+					if (date("d") == 2) {
+						$goamonth = date("m")-1;
+						if (date("m") == 1) {
+							$goayear = date("Y")-1;
+							$goamonth = "12";
+						}
+	
+						$statsdirold = $statsdir."/".$goayear."-".$goamonth."/";
+	
+						if(!is_dir($statsdirold)) {
+							 $app->system->mkdirpath($statsdirold, 0755, $username, $groupname);
+						}
 
-					$app->system->copy($output_html, $statsdirold);
-					$app->system->unlink($output_html);
+						// don't rotate db files per month
+						//rename($goa_db_dir, $statsdirold.'db');
+						//mkdir($goa_db_dir);
 
 
-					$files = scandir($statsdir);
+						$files = scandir($statsdir);
 
-					foreach ($files as $file) {
-						if (substr($file, 0, 1) != "." && !is_dir("$statsdir"."/"."$file") && substr($file, 0, 1) != "w" && substr($file, 0, 1) != "i") $app->system->copy("$statsdir"."/"."$file", "$statsdirold"."$file");
+						foreach ($files as $file) {
+							if (substr($file, 0, 1) != "." && !is_dir("$statsdir"."/"."$file") && substr($file, 0, 1) != "w" && substr($file, 0, 1) != "i") $app->system->copy("$statsdir"."/"."$file", "$statsdirold"."$file");
+						}
 					}
-				}
-
-				// Get the GoAccess version
-				$match = array();
 
-				$goaccess_version = $app->system->system_safe('goaccess --version 2>&1');
+					// Get the GoAccess version
+					$match = array();
+	
+					$goaccess_version = $app->system->system_safe('goaccess --version 2>&1');
 
-				if(preg_match('/[0-9]\.[0-9]{1,2}/', $goaccess_version, $match)) {
-					$goaccess_version = $match[0];
-				}
+					if(preg_match('/[0-9]\.[0-9]{1,2}/', $goaccess_version, $match)) {
+						$goaccess_version = $match[0];
+					}
 
 
-				/*
-				 * GoAccess removed with 1.4 btree support and supports from this version on only "In-Memory with On-Disk Persitance Storage".
-				 * For versions prior 1.4 you need GoAccess with btree support compiled!
-				 */
+					/*
+					 * GoAccess removed with 1.4 btree support and supports from this version on only "In-Memory with On-Disk Persitance Storage".
+					 * For versions prior 1.4 you need GoAccess with btree support compiled!
+					 */
 				
-				$cust_lang = $conf['language']."_".strtoupper($conf['language']);
-
-				if(version_compare($goaccess_version,1.4) >= 0) {
-					$app->system->exec_safe("LANG=? goaccess -f ? --config-file ? --restore --persist --db-path=? --output=?", $cust_lang, $logfile, $goaccess_conf, $goa_db_dir, $output_html);
-				} else {
-					$output = $app->system->system_safe('goaccess --help 2>&1');
-					preg_match('/keep-db-files/', $output, $match);
-					if($match[0] == "keep-db-files") {
-						$app->system->exec_safe("LANG=? goaccess -f ? --config-file ? --load-from-disk --keep-db-files --db-path=? --output=?", $cust_lang, $logfile, $goaccess_conf, $goa_db_dir, $output_html);
-					} else {
-	                                        $app->log("Stats not generated. The GoAccess binary was not compiled with btree support. Please recompile/reinstall GoAccess with btree support, or install GoAccess version >= 1.4!", LOGLEVEL_ERROR);
-					}
-	                                unset($output);
-				}
-				unset($cust_lang);
+					$cust_lang = $conf['language']."_".strtoupper($conf['language']);
 
-				if(!is_file($rec['document_root']."/".$web_folder."/stats/index.php")) {
-					if(file_exists("/usr/local/ispconfig/server/conf-custom/goaccess_index.php.master")) {
-						$app->system->copy("/usr/local/ispconfig/server/conf-custom/goaccess_index.php.master", $rec['document_root']."/".$web_folder."/stats/index.php");
+					if(version_compare($goaccess_version,1.4) >= 0) {
+						$app->system->exec_safe("LANG=? goaccess -f ? --config-file ? --restore --persist --db-path=? --output=?", $cust_lang, $logfile, $goaccess_conf, $goa_db_dir, $output_html);
 					} else {
-						$app->system->copy("/usr/local/ispconfig/server/conf/goaccess_index.php.master", $rec['document_root']."/".$web_folder."/stats/index.php");
+						$output = $app->system->system_safe('goaccess --help 2>&1');
+						preg_match('/keep-db-files/', $output, $match);
+						if($match[0] == "keep-db-files") {
+							$app->system->exec_safe("LANG=? goaccess -f ? --config-file ? --load-from-disk --keep-db-files --db-path=? --output=?", $cust_lang, $logfile, $goaccess_conf, $goa_db_dir, $output_html);
+						} else {
+		                                        $app->log("Stats not generated. The GoAccess binary was not compiled with btree support. Please recompile/reinstall GoAccess with btree support, or install GoAccess version >= 1.4!", LOGLEVEL_ERROR);
+						}
+		                                unset($output);
+					}
+					unset($cust_lang);
+	
+					if(!is_file($rec['document_root']."/".$web_folder."/stats/index.php")) {
+						if(file_exists("/usr/local/ispconfig/server/conf-custom/goaccess_index.php.master")) {
+							$app->system->copy("/usr/local/ispconfig/server/conf-custom/goaccess_index.php.master", $rec['document_root']."/".$web_folder."/stats/index.php");
+						} else {
+							$app->system->copy("/usr/local/ispconfig/server/conf/goaccess_index.php.master", $rec['document_root']."/".$web_folder."/stats/index.php");
+						}
 					}
-				}
 
-	                        $app->log('Created GoAccess statistics for ' . $domain, LOGLEVEL_DEBUG);
-	                        if(is_file($rec['document_root']."/".$web_folder."/stats/index.php")) {
-	                                $app->system->chown($rec['document_root']."/".$web_folder."/stats/index.php", $rec['system_user']);
-	                                $app->system->chgrp($rec['document_root']."/".$web_folder."/stats/index.php", $rec['system_group']);
-	                        }
+		                        $app->log('Created GoAccess statistics for ' . $domain, LOGLEVEL_DEBUG);
+		                        if(is_file($rec['document_root']."/".$web_folder."/stats/index.php")) {
+		                                $app->system->chown($rec['document_root']."/".$web_folder."/stats/index.php", $rec['system_user']);
+		                                $app->system->chgrp($rec['document_root']."/".$web_folder."/stats/index.php", $rec['system_group']);
+		                        }
 
-				$app->system->exec_safe('chown -R ?:? ?', $username, $groupname, $statsdir);
+					$app->system->exec_safe('chown -R ?:? ?', $username, $groupname, $statsdir);
+				}
+			} else {
+				$app->log("Stats not generated. The GoAccess binary couldn't be found. Make sure that GoAccess is installed and that it is in \$PATH", LOGLEVEL_ERROR);
 			}
 
-	} else {
-		$app->log("Stats not generated. The GoAccess binary couldn't be found. Make sure that GoAccess is installed and that it is in \$PATH", LOGLEVEL_ERROR);
-	}
+		} 
 
 		parent::onRunJob();
 	}