diff --git a/interface/web/sites/ajax_get_json.php b/interface/web/sites/ajax_get_json.php
index 3ad14638d6d428139b52bd2e7c4eb925cd4b5ad4..26e821149f3b3e74559883b9490ab051a1ef0516 100644
--- a/interface/web/sites/ajax_get_json.php
+++ b/interface/web/sites/ajax_get_json.php
@@ -34,6 +34,8 @@ require_once('../../lib/app.inc.php');
 //* Check permissions for module
 $app->auth->check_module_permissions('sites');
 
+$app->uses('getconf');
+
 $server_id = intval($_GET["server_id"]);
 $web_id = intval($_GET["web_id"]);
 $type = $_GET["type"];
@@ -43,7 +45,6 @@ $type = $_GET["type"];
 	if($type == 'getservertype'){
 		$json = '{"servertype":"';
 		$server_type = 'apache';
-		$app->uses('getconf');
 		$web_config = $app->getconf->get_server_config($server_id, 'web');
 		if(!empty($web_config['server_type'])) $server_type = $web_config['server_type'];
 		$json .= $server_type;
@@ -62,12 +63,24 @@ $type = $_GET["type"];
 	
 	if($type == 'getphpfastcgi'){
 		$json = '{';
-		$sql = "SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = $server_id";
+		
+		$server_type = 'apache';
+		$web_config = $app->getconf->get_server_config($server_id, 'web');
+		if(!empty($web_config['server_type'])) $server_type = $web_config['server_type'];
+		if($server_type == 'nginx'){
+			$sql = "SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = $server_id";
+		} else {
+			$sql = "SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = $server_id";
+		}
 		$php_records = $app->db->queryAllRecords($sql);
 		$php_select = "";
 		if(is_array($php_records) && !empty($php_records)) {
 			foreach( $php_records as $php_record) {
-				$php_version = $php_record['name'].':'.$php_record['php_fastcgi_binary'].':'.$php_record['php_fastcgi_ini_dir'];
+				if($server_type == 'nginx'){
+					$php_version = $php_record['name'].':'.$php_record['php_fpm_init_script'].':'.$php_record['php_fpm_ini_dir'].':'.$php_record['php_fpm_pool_dir'];
+				} else {
+					$php_version = $php_record['name'].':'.$php_record['php_fastcgi_binary'].':'.$php_record['php_fastcgi_ini_dir'];
+				}
 				$json .= '"'.$php_version.'": "'.$php_record['name'].'",';
 			}
 		}
diff --git a/interface/web/sites/web_domain_edit.php b/interface/web/sites/web_domain_edit.php
index a372a5bdd58c245fb9c0f62a317b471a5ada26e8..d74fae3ad9e89ae97126d17fd754360b504a1750 100644
--- a/interface/web/sites/web_domain_edit.php
+++ b/interface/web/sites/web_domain_edit.php
@@ -86,6 +86,8 @@ class page_action extends tform_actions {
 
 	function onShowEnd() {
 		global $app, $conf;
+		
+		$app->uses('ini_parser,getconf');
 
 		//* Client: If the logged in user is not admin and has no sub clients (no reseller)
 		if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) {
@@ -130,12 +132,23 @@ class page_action extends tform_actions {
 			unset($ips);
 			
 			//PHP Version Selection (FastCGI)
-			$sql = "SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = ".$client['default_webserver']." AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")";
+			$server_type = 'apache';
+			$web_config = $app->getconf->get_server_config($client['default_webserver'], 'web');
+			if(!empty($web_config['server_type'])) $server_type = $web_config['server_type'];
+			if($server_type == 'nginx'){
+				$sql = "SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = ".$client['default_webserver']." AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")";
+			} else {
+				$sql = "SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = ".$client['default_webserver']." AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")";
+			}
 			$php_records = $app->db->queryAllRecords($sql);
 			$php_select = "<option value=''>Default</option>";
 			if(is_array($php_records) && !empty($php_records)) {
 				foreach( $php_records as $php_record) {
-					$php_version = $php_record['name'].':'.$php_record['php_fastcgi_binary'].':'.$php_record['php_fastcgi_ini_dir'];
+					if($server_type == 'nginx'){
+						$php_version = $php_record['name'].':'.$php_record['php_fpm_init_script'].':'.$php_record['php_fpm_ini_dir'].':'.$php_record['php_fpm_pool_dir'];
+					} else {
+						$php_version = $php_record['name'].':'.$php_record['php_fastcgi_binary'].':'.$php_record['php_fastcgi_ini_dir'];
+					}
 					$selected = ($php_version == $this->dataRecord["fastcgi_php_version"])?'SELECTED':'';
 					$php_select .= "<option value='$php_version' $selected>".$php_record['name']."</option>\r\n";
 				}
@@ -200,12 +213,23 @@ class page_action extends tform_actions {
 			unset($ips);
 			
 			//PHP Version Selection (FastCGI)
-			$sql = "SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = ".$client['default_webserver']." AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")";
+			$server_type = 'apache';
+			$web_config = $app->getconf->get_server_config($client['default_webserver'], 'web');
+			if(!empty($web_config['server_type'])) $server_type = $web_config['server_type'];
+			if($server_type == 'nginx'){
+				$sql = "SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = ".$client['default_webserver']." AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")";
+			} else {
+				$sql = "SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = ".$client['default_webserver']." AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")";
+			}
 			$php_records = $app->db->queryAllRecords($sql);
 			$php_select = "<option value=''>Default</option>";
 			if(is_array($php_records) && !empty($php_records)) {
 				foreach( $php_records as $php_record) {
-					$php_version = $php_record['name'].':'.$php_record['php_fastcgi_binary'].':'.$php_record['php_fastcgi_ini_dir'];
+					if($server_type == 'nginx'){
+						$php_version = $php_record['name'].':'.$php_record['php_fpm_init_script'].':'.$php_record['php_fpm_ini_dir'].':'.$php_record['php_fpm_pool_dir'];
+					} else {
+						$php_version = $php_record['name'].':'.$php_record['php_fastcgi_binary'].':'.$php_record['php_fastcgi_ini_dir'];
+					}
 					$selected = ($php_version == $this->dataRecord["fastcgi_php_version"])?'SELECTED':'';
 					$php_select .= "<option value='$php_version' $selected>".$php_record['name']."</option>\r\n";
 				}
@@ -256,12 +280,23 @@ class page_action extends tform_actions {
 			unset($ips);
 			
 			//PHP Version Selection (FastCGI)
-			$sql = "SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = $server_id";
+			$server_type = 'apache';
+			$web_config = $app->getconf->get_server_config($server_id, 'web');
+			if(!empty($web_config['server_type'])) $server_type = $web_config['server_type'];
+			if($server_type == 'nginx'){
+				$sql = "SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = $server_id";
+			} else {
+				$sql = "SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = $server_id";
+			}
 			$php_records = $app->db->queryAllRecords($sql);
 			$php_select = "<option value=''>Default</option>";
 			if(is_array($php_records) && !empty($php_records)) {
 				foreach( $php_records as $php_record) {
-					$php_version = $php_record['name'].':'.$php_record['php_fastcgi_binary'].':'.$php_record['php_fastcgi_ini_dir'];
+					if($server_type == 'nginx'){
+						$php_version = $php_record['name'].':'.$php_record['php_fpm_init_script'].':'.$php_record['php_fpm_ini_dir'].':'.$php_record['php_fpm_pool_dir'];
+					} else {
+						$php_version = $php_record['name'].':'.$php_record['php_fastcgi_binary'].':'.$php_record['php_fastcgi_ini_dir'];
+					}
 					$selected = ($php_version == $this->dataRecord["fastcgi_php_version"])?'SELECTED':'';
 					$php_select .= "<option value='$php_version' $selected>".$php_record['name']."</option>\r\n";
 				}
@@ -314,7 +349,6 @@ class page_action extends tform_actions {
 		 * Now we have to check, if we should use the domain-module to select the domain
 		 * or not
 		 */
-		$app->uses('ini_parser,getconf');
 		$settings = $app->getconf->get_global_config('domains');
 		if ($settings['use_domain_module'] == 'y') {
 			/*
diff --git a/server/plugins-available/nginx_plugin.inc.php b/server/plugins-available/nginx_plugin.inc.php
index 149a4d1ce7cf09305d4f0a95d5c3c1b2339ed398..8e327db2224a045152237d333c1cc788acec3ef7 100644
--- a/server/plugins-available/nginx_plugin.inc.php
+++ b/server/plugins-available/nginx_plugin.inc.php
@@ -712,7 +712,20 @@ class nginx_plugin {
 		if($data['new']['ipv6_address'] != '') $tpl->setVar('ipv6_enabled', 1);
 		
 		// PHP-FPM
-		$pool_dir = escapeshellcmd($web_config['php_fpm_pool_dir']);
+		// Support for multiple PHP versions
+		if(trim($data['new']['fastcgi_php_version']) != ''){
+			$default_php_fpm = false;
+			list($custom_php_fpm_name, $custom_php_fpm_init_script, $custom_php_fpm_ini_dir, $custom_php_fpm_pool_dir) = explode(':', trim($data['new']['fastcgi_php_version']));
+			if(substr($custom_php_fpm_ini_dir,-1) != '/') $custom_php_fpm_ini_dir .= '/';
+		} else {
+			$default_php_fpm = true;
+		}
+		
+		if($default_php_fpm){
+			$pool_dir = escapeshellcmd($web_config['php_fpm_pool_dir']);
+		} else {
+			$pool_dir = $custom_php_fpm_pool_dir;
+		}
 		if(substr($pool_dir,-1) != '/') $pool_dir .= '/';
 		$pool_name = 'web'.$data['new']['domain_id'];
 		$socket_dir = escapeshellcmd($web_config['php_fpm_socket_dir']);
@@ -1386,6 +1399,14 @@ class nginx_plugin {
 		global $app, $conf;
 		//$reload = false;
 		
+		if(trim($data['new']['fastcgi_php_version']) != ''){
+			$default_php_fpm = false;
+			list($custom_php_fpm_name, $custom_php_fpm_init_script, $custom_php_fpm_ini_dir, $custom_php_fpm_pool_dir) = explode(':', trim($data['new']['fastcgi_php_version']));
+			if(substr($custom_php_fpm_ini_dir,-1) != '/') $custom_php_fpm_ini_dir .= '/';
+		} else {
+			$default_php_fpm = true;
+		}
+		
 		if($data['new']['php'] == 'no'){
 			if(@is_file($pool_dir.$pool_name.'.conf')){
 				unlink($pool_dir.$pool_name.'.conf');
@@ -1474,6 +1495,36 @@ class nginx_plugin {
 		file_put_contents($pool_dir.$pool_name.'.conf',$tpl->grab());
 		$app->log('Writing the PHP-FPM config file: '.$pool_dir.$pool_name.'.conf',LOGLEVEL_DEBUG);
 		unset($tpl);
+		
+		// delete pool in all other PHP versions
+		$default_pool_dir = escapeshellcmd($web_config['php_fpm_pool_dir']);
+		if(substr($default_pool_dir,-1) != '/') $default_pool_dir .= '/';
+		if($default_pool_dir != $pool_dir){
+			if ( @is_file($default_pool_dir.$pool_name.'.conf') ) {
+					unlink($default_pool_dir.$pool_name.'.conf');
+					$app->log('Removed PHP-FPM config file: '.$default_pool_dir.$pool_name.'.conf',LOGLEVEL_DEBUG);
+					exec($conf['init_scripts'] . '/' . $web_config['php_fpm_init_script'] . ' reload');
+			}
+		}
+		$php_versions = $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 = ".$conf["server_id"]);
+		if(is_array($php_versions) && !empty($php_versions)){
+			foreach($php_versions as $php_version){
+				if(substr($php_version['php_fpm_pool_dir'],-1) != '/') $php_version['php_fpm_pool_dir'] .= '/';
+				if($php_version['php_fpm_pool_dir'] != $pool_dir){
+					if ( @is_file($php_version['php_fpm_pool_dir'].$pool_name.'.conf') ) {
+						unlink($php_version['php_fpm_pool_dir'].$pool_name.'.conf');
+						$app->log('Removed PHP-FPM config file: '.$php_version['php_fpm_pool_dir'].$pool_name.'.conf',LOGLEVEL_DEBUG);
+						exec($php_version['php_fpm_init_script'] . ' reload');
+					}
+				}
+			}
+		}
+		// Reload current PHP-FPM after all others
+		if(!$default_php_fpm){
+			sleep(1);
+			exec($custom_php_fpm_init_script . ' reload');
+		}
+		
 		//$reload = true;
 
 		//if($reload == true) $app->services->restartService('php-fpm','reload');
@@ -1481,17 +1532,61 @@ class nginx_plugin {
 	
 	//* Delete the PHP-FPM pool configuration file
 	private function php_fpm_pool_delete ($data,$web_config) {
-		global $app;
+		global $app, $conf;
+		
+		if(trim($data['old']['fastcgi_php_version']) != ''){
+			$default_php_fpm = false;
+			list($custom_php_fpm_name, $custom_php_fpm_init_script, $custom_php_fpm_ini_dir, $custom_php_fpm_pool_dir) = explode(':', trim($data['old']['fastcgi_php_version']));
+			if(substr($custom_php_fpm_ini_dir,-1) != '/') $custom_php_fpm_ini_dir .= '/';
+		} else {
+			$default_php_fpm = true;
+		}
+		
+		if($default_php_fpm){
+			$pool_dir = escapeshellcmd($web_config['php_fpm_pool_dir']);
+		} else {
+			$pool_dir = $custom_php_fpm_pool_dir;
+		}
 		
-		$pool_dir = escapeshellcmd($web_config['php_fpm_pool_dir']);
 		if(substr($pool_dir,-1) != '/') $pool_dir .= '/';
 		$pool_name = 'web'.$data['old']['domain_id'];
 		
 		if ( @is_file($pool_dir.$pool_name.'.conf') ) {
 			unlink($pool_dir.$pool_name.'.conf');
 			$app->log('Removed PHP-FPM config file: '.$pool_dir.$pool_name.'.conf',LOGLEVEL_DEBUG);
+			
 			//$app->services->restartService('php-fpm','reload');
 		}
+		
+		// delete pool in all other PHP versions
+		$default_pool_dir = escapeshellcmd($web_config['php_fpm_pool_dir']);
+		if(substr($default_pool_dir,-1) != '/') $default_pool_dir .= '/';
+		if($default_pool_dir != $pool_dir){
+			if ( @is_file($default_pool_dir.$pool_name.'.conf') ) {
+					unlink($default_pool_dir.$pool_name.'.conf');
+					$app->log('Removed PHP-FPM config file: '.$default_pool_dir.$pool_name.'.conf',LOGLEVEL_DEBUG);
+					exec($conf['init_scripts'] . '/' . $web_config['php_fpm_init_script'] . ' reload');
+			}
+		}	
+		$php_versions = $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 = ".$data['old']['server_id']);
+		if(is_array($php_versions) && !empty($php_versions)){
+			foreach($php_versions as $php_version){
+				if(substr($php_version['php_fpm_pool_dir'],-1) != '/') $php_version['php_fpm_pool_dir'] .= '/';
+				if($php_version['php_fpm_pool_dir'] != $pool_dir){
+					if ( @is_file($php_version['php_fpm_pool_dir'].$pool_name.'.conf') ) {
+						unlink($php_version['php_fpm_pool_dir'].$pool_name.'.conf');
+						$app->log('Removed PHP-FPM config file: '.$php_version['php_fpm_pool_dir'].$pool_name.'.conf',LOGLEVEL_DEBUG);
+						exec($php_version['php_fpm_init_script'] . ' reload');
+					}
+				}
+			}
+		}
+		
+		// Reload current PHP-FPM after all others
+		if(!$default_php_fpm){
+			sleep(1);
+			exec($custom_php_fpm_init_script . ' reload');
+		}
 	}
 	
 	function client_delete($event_name,$data) {