From ca0b77f95a10f7d81714667557d4946ce5b50a9e Mon Sep 17 00:00:00 2001
From: ftimme <ft@falkotimme.com>
Date: Wed, 28 Sep 2011 04:49:55 -0400
Subject: [PATCH] - nginx: Changed ispconfig and apps vhost from using PHP-FPM TCP connections to sockets.

---
 install/lib/installer_base.lib.php |   24 +++++++++++++++++++-----
 1 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php
index f145e24..ab1f110 100644
--- a/install/lib/installer_base.lib.php
+++ b/install/lib/installer_base.lib.php
@@ -1472,12 +1472,18 @@
 			} else {
 				$apps_vhost_ip = $conf['web']['apps_vhost_ip'].':';
 			}
+			
+			$socket_dir = escapeshellcmd($conf['nginx']['php_fpm_socket_dir']);
+			if(substr($socket_dir,-1) != '/') $socket_dir .= '/';
+			if(!is_dir($socket_dir)) exec('mkdir -p '.$socket_dir);
+			$fpm_socket = $socket_dir.'apps.sock';
 
 			$content = str_replace('{apps_vhost_ip}', $apps_vhost_ip, $content);
 			$content = str_replace('{apps_vhost_port}', $conf['web']['apps_vhost_port'], $content);
 			$content = str_replace('{apps_vhost_dir}', $conf['web']['website_basedir'].'/apps', $content);
 			$content = str_replace('{apps_vhost_servername}', $apps_vhost_servername, $content);
-			$content = str_replace('{fpm_port}', ($conf['nginx']['php_fpm_start_port']+1), $content);
+			//$content = str_replace('{fpm_port}', ($conf['nginx']['php_fpm_start_port']+1), $content);
+			$content = str_replace('{fpm_socket}', $fpm_socket, $content);
 
 			wf($vhost_conf_dir.'/apps.vhost', $content);
 			
@@ -1485,7 +1491,8 @@
 			// Dont just copy over the php-fpm pool template but add some custom settings
 			$content = rf('tpl/apps_php_fpm_pool.conf.master');
 			$content = str_replace('{fpm_pool}', 'apps', $content);
-			$content = str_replace('{fpm_port}', ($conf['nginx']['php_fpm_start_port']+1), $content);
+			//$content = str_replace('{fpm_port}', ($conf['nginx']['php_fpm_start_port']+1), $content);
+			$content = str_replace('{fpm_socket}', $fpm_socket, $content);
 			$content = str_replace('{fpm_user}', $apps_vhost_user, $content);
 			$content = str_replace('{fpm_group}', $apps_vhost_group, $content);
 			wf($conf['nginx']['php_fpm_pool_dir'].'/apps.conf', $content);
@@ -1808,8 +1815,14 @@
 				$content = str_replace('{fastcgi_ssl}', 'off', $content);
 			}
 			
-			$content = str_replace('{fpm_port}', $conf['nginx']['php_fpm_start_port'], $content);
-
+			$socket_dir = escapeshellcmd($conf['nginx']['php_fpm_socket_dir']);
+			if(substr($socket_dir,-1) != '/') $socket_dir .= '/';
+			if(!is_dir($socket_dir)) exec('mkdir -p '.$socket_dir);
+			$fpm_socket = $socket_dir.'ispconfig.sock';
+			
+			//$content = str_replace('{fpm_port}', $conf['nginx']['php_fpm_start_port'], $content);
+			$content = str_replace('{fpm_socket}', $fpm_socket, $content);
+			
 			wf($vhost_conf_dir.'/ispconfig.vhost', $content);
 			
 			unset($content);
@@ -1818,7 +1831,8 @@
 			// Dont just copy over the php-fpm pool template but add some custom settings
 			$content = rf('tpl/php_fpm_pool.conf.master');
 			$content = str_replace('{fpm_pool}', 'ispconfig', $content);
-			$content = str_replace('{fpm_port}', $conf['nginx']['php_fpm_start_port'], $content);
+			//$content = str_replace('{fpm_port}', $conf['nginx']['php_fpm_start_port'], $content);
+			$content = str_replace('{fpm_socket}', $fpm_socket, $content);
 			$content = str_replace('{fpm_user}', 'ispconfig', $content);
 			$content = str_replace('{fpm_group}', 'ispconfig', $content);
 			wf($conf['nginx']['php_fpm_pool_dir'].'/ispconfig.conf', $content);

--
Gitblit v1.9.1