From 1c6da3502e13ca5391b5ece1349b8401876e4b99 Mon Sep 17 00:00:00 2001
From: Marius Cramer <m.cramer@pixcept.de>
Date: Wed, 30 Apr 2014 05:26:30 -0400
Subject: [PATCH] Implemented: FS#3266 - HHVM PHP mode support (some improvements, nginx support)

---
 server/conf/vhost.conf.master |   62 ++++++++++++++++++++++++------
 1 files changed, 49 insertions(+), 13 deletions(-)

diff --git a/server/conf/vhost.conf.master b/server/conf/vhost.conf.master
index 06a16fc..07f7a4a 100644
--- a/server/conf/vhost.conf.master
+++ b/server/conf/vhost.conf.master
@@ -20,7 +20,11 @@
 		<tmpl_if name='php' op='==' value='php-fpm'>
 		DocumentRoot <tmpl_var name='web_document_root'>
 		</tmpl_else>
-		DocumentRoot <tmpl_var name='web_document_root_www'>
+			<tmpl_if name='php' op='==' value='hhvm'>
+			DocumentRoot <tmpl_var name='web_document_root'>
+			</tmpl_else>
+			DocumentRoot <tmpl_var name='web_document_root_www'>
+			</tmpl_if>
 		</tmpl_if>
 	</tmpl_if>
 </tmpl_if>
@@ -156,7 +160,9 @@
 <tmpl_if name='python' op='==' value='y'>
 		<IfModule mod_python.c>
 			<Directory {tmpl_var name='web_document_root_www'}>
-				AddHandler mod_python .py
+				<FilesMatch "\.py$">
+					SetHandler mod_python
+				</FilesMatch>
 				PythonHandler mod_python.publisher
 				PythonDebug On
 			</Directory>
@@ -174,8 +180,9 @@
 			</tmpl_if>
 		</Directory>
 		ScriptAlias  /cgi-bin/ <tmpl_var name='document_root'>/cgi-bin/
-		AddHandler cgi-script .cgi
-		AddHandler cgi-script .pl
+		<FilesMatch "\.(cgi|pl)$">
+			SetHandler cgi-script
+		</FilesMatch>
 </tmpl_if>
 <tmpl_if name='suexec' op='==' value='y'>
 		# suexec enabled
@@ -202,13 +209,15 @@
 		# suphp enabled
 		<Directory {tmpl_var name='web_document_root'}>
 		<IfModule mod_suphp.c>
-				suPHP_Engine on
-				# suPHP_UserGroup <tmpl_var name='system_user'> <tmpl_var name='system_group'>
+			suPHP_Engine on
+			# suPHP_UserGroup <tmpl_var name='system_user'> <tmpl_var name='system_group'>
 <tmpl_if name='has_custom_php_ini'>
 	suPHP_ConfigPath <tmpl_var name='custom_php_ini_dir'>
 </tmpl_if>
-				AddHandler x-httpd-suphp .php .php3 .php4 .php5
-				suPHP_AddHandler x-httpd-suphp
+			<FilesMatch "\.php[345]?$">
+				SetHandler x-httpd-suphp
+			</FilesMatch>
+			suPHP_AddHandler x-httpd-suphp
 		</IfModule>
 		</Directory>
 </tmpl_if>
@@ -216,7 +225,9 @@
 		# php as cgi enabled
 		ScriptAlias /php5-cgi <tmpl_var name='cgi_starter_path'><tmpl_var name='cgi_starter_script'>
 		Action php5-cgi /php5-cgi
-		AddHandler php5-cgi .php .php3 .php4 .php5
+		<FilesMatch "\.php[345]?$">
+			SetHandler php5-cgi
+		</FilesMatch>
 		<Directory {tmpl_var name='cgi_starter_path'}>
 			<tmpl_if name='apache_version' op='>' value='2.2' format='version'>
 			Require all granted
@@ -253,7 +264,9 @@
 </tmpl_if>
 		</IfModule>
 		<Directory {tmpl_var name='web_document_root_www'}>
-				AddHandler fcgid-script .php .php3 .php4 .php5
+				<FilesMatch "\.php[345]?$">
+					SetHandler fcgid-script
+				</FilesMatch>
 				FCGIWrapper <tmpl_var name='fastcgi_starter_path'><tmpl_var name='fastcgi_starter_script'> .php
 				FCGIWrapper <tmpl_var name='fastcgi_starter_path'><tmpl_var name='fastcgi_starter_script'> .php3
 				FCGIWrapper <tmpl_var name='fastcgi_starter_path'><tmpl_var name='fastcgi_starter_script'> .php4
@@ -268,7 +281,9 @@
 				</tmpl_if>
 		</Directory>
 		<Directory {tmpl_var name='web_document_root'}>
-				AddHandler fcgid-script .php .php3 .php4 .php5
+				<FilesMatch "\.php[345]?$">
+					SetHandler fcgid-script
+				</FilesMatch>
 				FCGIWrapper <tmpl_var name='fastcgi_starter_path'><tmpl_var name='fastcgi_starter_script'> .php
 				FCGIWrapper <tmpl_var name='fastcgi_starter_path'><tmpl_var name='fastcgi_starter_script'> .php3
 				FCGIWrapper <tmpl_var name='fastcgi_starter_path'><tmpl_var name='fastcgi_starter_script'> .php4
@@ -293,7 +308,9 @@
 					Allow from all
 					</tmpl_if>
 			    </Directory>
-                AddHandler php5-fcgi .php .php3 .php4 .php5
+				<FilesMatch "\.php[345]?$">
+					SetHandler php5-fcgi
+				</FilesMatch>
                 Action php5-fcgi /php5-fcgi
 				Alias /php5-fcgi {tmpl_var name='document_root'}/cgi-bin/php5-fcgi-{tmpl_var name='ip_address'}-{tmpl_var name='port'}-{tmpl_var name='domain'}
 <tmpl_if name='use_tcp'>
@@ -302,6 +319,25 @@
 <tmpl_if name='use_socket'>
                 FastCgiExternalServer {tmpl_var name='document_root'}/cgi-bin/php5-fcgi-{tmpl_var name='ip_address'}-{tmpl_var name='port'}-{tmpl_var name='domain'} -idle-timeout 300 -socket <tmpl_var name='fpm_socket'> -pass-header Authorization
 </tmpl_if>
+		</IfModule>
+</tmpl_if>
+
+<tmpl_if name='php' op='==' value='hhvm'>
+		<IfModule mod_fastcgi.c>
+				<Directory {tmpl_var name='document_root'}/cgi-bin>
+					<tmpl_if name='apache_version' op='>' value='2.2' format='version'>
+					Require all granted
+					<tmpl_else>
+					Order allow,deny
+					Allow from all
+					</tmpl_if>
+			    </Directory>
+				<FilesMatch "\.php[345]?$">
+					SetHandler php5-fcgi
+				</FilesMatch>
+                Action php5-fcgi /php5-fcgi
+				Alias /php5-fcgi {tmpl_var name='document_root'}/cgi-bin/php5-fcgi-{tmpl_var name='ip_address'}-{tmpl_var name='port'}-{tmpl_var name='domain'}
+                FastCgiExternalServer {tmpl_var name='document_root'}/cgi-bin/php5-fcgi-{tmpl_var name='ip_address'}-{tmpl_var name='port'}-{tmpl_var name='domain'} -idle-timeout 300 -socket /var/run/hhvm/hhvm.<tmpl_var name='system_user'>.sock -pass-header Authorization
 		</IfModule>
 </tmpl_if>
 
@@ -351,4 +387,4 @@
 
 <tmpl_var name='apache_directives'>
 </VirtualHost>
-</tmpl_loop>
\ No newline at end of file
+</tmpl_loop>

--
Gitblit v1.9.1