apache: fastcgi config core, implement php5-cgi fastcgi release_20170127
authorClinton Ebadi <clinton@unknownlamer.org>
Sun, 29 Jan 2017 03:21:30 +0000 (22:21 -0500)
committerClinton Ebadi <clinton@unknownlamer.org>
Sun, 29 Jan 2017 03:21:30 +0000 (22:21 -0500)
New fastcgi wrapper configuration to set up environment for user to
run fastcgi scripts.

Implemented support for using fastcgi with php5-cgi using version 6
since it does not exist in the real world. phpFastCgiWrapper is site
specific and should set whatever php environment variables are needed
and exec php5-cgi. This does not work with php-fpm, only old-style
php5-cgi in fastcgi mode with mod_fcgid.

todo: general fastcgi directives

configDefault/apache.cfg
configDefault/apache.csg
lib/apache.dtl
src/plugins/apache.sml

index 0636c4f..83b2a28 100644 (file)
@@ -58,6 +58,24 @@ fun backupLogDirOf version1 =
     else
        ConfigCore.sharedRoot ^ "/backup/apache2/"
 
+fun fastCgiWrapperOf user =
+      if size user < 2 then
+       "/bad_username"
+    else
+       String.concat [ConfigCore.sharedRoot,
+                      "/httpd/fastcgi/",
+                      String.substring (user, 0, 1),
+                      "/",
+                      String.substring (user, 0, 2),
+                      "/",
+                      user,
+                      "/",
+                      user,
+                      "-wrapper-wrapper"]
+
+(* FIXME: hcoop reference *)
+val phpFastCgiWrapper = "/afs/hcoop.net/common/bin/php5-fcgi-wrapper"
+
 val defaultPhpVersion = 5
 
 val waklogUserFile = ConfigCore.localRoot ^ "/waklog.conf"
index 908fc49..d81f912 100644 (file)
@@ -25,8 +25,10 @@ signature APACHE_CONFIG = sig
     val logDirOf : bool -> string -> string
     val realLogDirOf : string -> string
     val backupLogDirOf : bool -> string
+    val fastCgiWrapperOf : string -> string
 
     val defaultPhpVersion : int
+    val phpFastCgiWrapper : string
 
     val waklogUserFile : string
 
index c8fc51c..afd1eb0 100644 (file)
@@ -35,6 +35,7 @@ extern val use_cert : ssl_cert_path -> ssl;
 
 extern type php_version;
 extern val php5 : php_version;
+extern val fast_php : php_version;
 
 extern val vhost : host -> Vhost => [Domain]
   {WebPlaces : [web_place],
index b7d36a4..c4b47af 100644 (file)
@@ -467,7 +467,8 @@ fun vhostPost () = (!post ();
                    app (TextIO.closeOut o #2) (!vhostFiles))
 
 val php_version = fn (EVar "php5", _) => SOME 5
-                  | _ => NONE
+                   | (EVar "fast_php", _) => SOME 6
+                   | _ => NONE
 
 fun vhostBody (env, makeFullHost) =
     let
@@ -551,14 +552,23 @@ fun vhostBody (env, makeFullHost) =
                                  TextIO.output (file, user);
                                  TextIO.output (file, "/DAVLock");
 
-                                 if php <> Config.Apache.defaultPhpVersion then
+                                 if php = Config.Apache.defaultPhpVersion
+                                 then
+                                     ()
+                                 else if php = 6
+                                 then
+                                     (* fastcgi php 5.6 since 6 doesn't exist *)
+                                     (TextIO.output (file, "\n\tAddHandler fcgid-script .php .phtml");
+                                      TextIO.output (file, "\n\tFcgidWrapper \"");
+                                      TextIO.output (file, Config.Apache.fastCgiWrapperOf user);
+                                      TextIO.output (file, " ");
+                                      TextIO.output (file, Config.Apache.phpFastCgiWrapper);
+                                      TextIO.output (file, "\""))
+                                 else
                                      (TextIO.output (file, "\n\tAddHandler x-httpd-php");
                                       TextIO.output (file, Int.toString php);
-                                      TextIO.output (file, " .php .phtml"))
-                                 else
-                                     ();
-
-                                 (ld, file)
+                                      TextIO.output (file, " .php .phtml"));
+                         (ld, file)
                              end)
                          places;
        write "\n\tDocumentRoot ";