@@ -374,6 +374,43 @@ function update($event_name,$data) {
374374 }
375375 $ tpl ->setLoop ('redirects ' ,$ rewrite_rules );
376376
377+ /**
378+ * install fast-cgi starter script and add script aliasd config
379+ * first we create the script directory if not already created, then copy over the starter script
380+ * settings are copied over from the server ini config for now
381+ * TODO: Create form for fastcgi configs per site.
382+ */
383+
384+ if ($ data ["new " ]["php " ] == "fast-cgi " )
385+ {
386+ $ fastcgi_starter_path = str_replace ("[system_user] " ,$ data ["new " ]["system_user " ],$ web_config ["fastcgi_starter_path " ]);
387+ if (!is_dir ($ fastcgi_starter_path ))
388+ {
389+ exec ("mkdir $ fastcgi_starter_path " );
390+ exec ("chown " .$ data ["new " ]["system_user " ].": " .$ data ["new " ]["system_group " ]." $ fastcgi_starter_path " );
391+ }
392+
393+ $ fcgi_tpl = new tpl ();
394+ $ fcgi_tpl ->newTemplate ("php-fcgi-starter.master " );
395+
396+ $ fcgi_tpl ->setVar ('php_ini_path ' ,$ web_config ["fastcgi_phpini_path " ]);
397+ $ fcgi_tpl ->setVar ('document_root ' ,$ data ["new " ]["document_root " ]);
398+ $ fcgi_tpl ->setVar ('php_fcgi_children ' ,$ web_config ["fastcgi_children " ]);
399+ $ fcgi_tpl ->setVar ('php_fcgi_max_requests ' ,$ web_config ["fastcgi_max_requests " ]);
400+ $ fcgi_tpl ->setVar ('php_fcgi_bin ' ,$ web_config ["fastcgi_bin " ]);
401+
402+ $ fcgi_starter_script = escapeshellcmd ($ fastcgi_starter_path ."/ " .$ web_config ["fastcgi_starter_script " ]);
403+ file_put_contents ($ fcgi_starter_script ,$ fcgi_tpl ->grab ());
404+ unset($ fcgi_tpl );
405+
406+ exec ("chmod 755 $ fcgi_starter_script " );
407+ exec ("chown " .$ data ["new " ]["system_user " ].": " .$ data ["new " ]["system_group " ]." $ fcgi_starter_script " );
408+
409+ $ tpl ->setVar ('fastcgi_alias ' ,$ web_config ["fastcgi_alias " ]);
410+ $ tpl ->setVar ('fastcgi_starter_path ' ,$ fastcgi_starter_path );
411+
412+ }
413+
377414 $ vhost_file = escapeshellcmd ($ web_config ["vhost_conf_dir " ].'/ ' .$ data ["new " ]["domain " ].'.vhost ' );
378415 file_put_contents ($ vhost_file ,$ tpl ->grab ());
379416 $ app ->log ("Writing the vhost file: $ vhost_file " ,LOGLEVEL_DEBUG );
0 commit comments