From 42782c7938b390dacda93c64ff4850b1a49f3c11 Mon Sep 17 00:00:00 2001 From: Clinton Ebadi Date: Sat, 28 Jan 2017 22:21:30 -0500 Subject: [PATCH] apache: fastcgi config core, implement php5-cgi fastcgi 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 | 18 ++++++++++++++++++ configDefault/apache.csg | 2 ++ lib/apache.dtl | 1 + src/plugins/apache.sml | 24 +++++++++++++++++------- 4 files changed, 38 insertions(+), 7 deletions(-) diff --git a/configDefault/apache.cfg b/configDefault/apache.cfg index 0636c4f..83b2a28 100644 --- a/configDefault/apache.cfg +++ b/configDefault/apache.cfg @@ -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" diff --git a/configDefault/apache.csg b/configDefault/apache.csg index 908fc49..d81f912 100644 --- a/configDefault/apache.csg +++ b/configDefault/apache.csg @@ -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 diff --git a/lib/apache.dtl b/lib/apache.dtl index c8fc51c..afd1eb0 100644 --- a/lib/apache.dtl +++ b/lib/apache.dtl @@ -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], diff --git a/src/plugins/apache.sml b/src/plugins/apache.sml index b7d36a4..c4b47af 100644 --- a/src/plugins/apache.sml +++ b/src/plugins/apache.sml @@ -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 "; -- 2.20.1