The upcoming release of kbmMW Enterprise Edition also adds support for FastCGI!

The upcoming release of kbmMW Enterprise Edition also adds support for FastCGI!

In fact your future kbmMW based sites will be able to combine any FastCGI enabled technology with kbmMWs own built in HTML handling, in one application.

The attachments shows a standard PHPSQliteCMS (http://phpsqlitecms.net/) installation being served by kbmMW.

kbmMW on Windows will be able to spawn relevant FastCGI servers automatically. kbmMW on ALL platforms (including mobile) will be able to take advantage of any number of external FastCGI servers.

This is the code required to setup kbmMW to act as a web server serving PHP pages:

procedure TForm1.FormCreate(Sender: TObject);
var
   sd:TkbmMWHTTPFastCGIServiceDefinition;
   sl:TkbmMWConnectionStringArray;
begin

sd:=TkbmMWHTTPFastCGIServiceDefinition(kbmMWServer1.RegisterService(TFastCGIHTTPService,false));

     // Its possible to define a default file name if no file is
     // referenced. As we define a PHP FastCGI site, index.pbp is
     // typically the default.
     // Its also possible to define the default via an URL rewrite.
     // See further down.
     //     sd.DefaultFile:='index.php';

     // Define the root of all resources for the PHP site.
     // Actual .php files are placed in the mwhfcOther category.
     // Typically these values all points to the same PHP webapp
     // root directory.
     // The directory is seen from the current directory of
     // the kbmMW server.
     sd.RootPath[mwhfcHTML]:='phpsqlitecms';
     sd.RootPath[mwhfcImage]:=sd.RootPath[mwhfcHTML];
     sd.RootPath[mwhfcJavascript]:=sd.RootPath[mwhfcHTML];
     sd.RootPath[mwhfcStyleSheet]:=sd.RootPath[mwhfcHTML];
     sd.RootPath[mwhfcOther]:=sd.RootPath[mwhfcHTML];

     // Most FastCGI servers require these settings to be made.
     // ServerName and ServerPort is the name/port for which the server
     // is accessed from the "outside" before any NAT translations
     // or proxying.
     sd.ServerName:='192.168.1.103';
     sd.ServerPort:=80;

     // Define how to connect to FastCGI servers serving
     // this PHP application.
     // Here we define one local PHP FastCGI server (the group
     // name is not relevant as such but is used to separate
     // different FastCGI instances from eachother).
     // More can be defined as separate groups. kbmMW will then
     // round robin loadbalance requests to them.
     // As a minimum IP and Port entries must be defined for
     // a FastCGI server.
     // Optionally Launch and Parameters can be defined,
     // to let kbmMW automatically start FastCGI servers as needed.
     sl:=TkbmMWConnectionStringArray.Create;
     try
        sl.Add('<|local|>');
        sl.Add('IP=192.168.1.103');
        sl.Add('Port=8764');
        sl.Add('Launch=c:\PHP\php-cgi.exe');
        sl.Add('Parameters=-b 192.168.1.103:8764');

        // Rewrite any url for files not found.
        sd.Rewrites.Add('^/cms/(.)$',
                        '/cms/index.php?qs=$1',
                        [mwhuroIfFileNotExists,mwhuroBreak]);
        sd.Rewrites.Add('^/(.)$',
                        '/index.php?qs=$1',
                        [mwhuroIfFileNotExists,mwhuroBreak]);

        sd.FastCGIModules.RegisterFastCGIModule(
           KBMMW_FASTCGI_URL_MASK_PHP,sl,
           'C:\svn_c4d\kbmmw\trunk\demos\FastCGIServer\phpsqlitecms'
           );
     finally
        sl.Free;
     end;
end;

As usual you can intercept all requests and responses, using standard kbmMW functionality, and thus let kbmMW handle some requests directly, while it forwards others to the FastCGI servers as needed.

The attachments shows the PHPSqliteCMS installation in full operation, including the administration pages, with a slight textual change to show that kbmMW is driving the site!

best regards
Kim Madsen
C4D
www.components4developers.com



Comments