PHP applications

PHP applications should run either under FastCGI or CGI - the configuration is nearly identical in both cases.

The following sample should get you started, however this page is far from complete and you will probably need to add more handler mappings for most PHP applications.

WebServer myServer = new WebServer();
myServer.LocalRoot = @"c:\MinnowRoot";
myServer.RootUrl = "/Temporary_Listen_Addresses/";

FastCgiHandler fastCgiHandler = new FastCgiHandler();
fastCgiHandler.CommandLine = @"c:\php\php-cgi.exe";
myServer.HandlerMappings.Add(new HandlerMapping("*.php", fastCgiHandler));

// Uncomment the following block and comment out the above block if you wish to 
// use CGI instead of FastCGI
/* CgiHandler cgiHandler = new CgiHandler();
cgiHandler.Executable = @"c:\php\php-cgi.exe";
myServer.HandlerMappings.Add(new HandlerMapping("*.php", cgiHandler)); */

StaticHandler staticHandler = new StaticHandler();
myServer.HandlerMappings.Add(new HandlerMapping("*.css", staticHandler));
myServer.HandlerMappings.Add(new HandlerMapping("*.js", staticHandler));
myServer.HandlerMappings.Add(new HandlerMapping("*.gif", staticHandler));
myServer.HandlerMappings.Add(new HandlerMapping("*.ico", staticHandler));
myServer.HandlerMappings.Add(new HandlerMapping("*.png", staticHandler));
myServer.HandlerMappings.Add(new HandlerMapping("*.html", staticHandler));


The FastCGI handler is recommended as the default mechanism of hosting PHP applications, however the FastCGIHandler is more complex / less likely to work than the CGI handler, and so if you experience any problems you might want to give the CGI handler a try until any issues with the FastCGI handler are ironed out.

Last edited Aug 3, 2010 at 11:14 AM by Kragen2uk, version 2


No comments yet.