Using Pike on the Web

[ Start > PikeDevel > Using Pike on the Web ] [ Edit this Page | Show Page Versions | Show Formatted ]

__Writing Standalone Apps__


Pike 7.7 and newer include the Web.CGI module, which can be used to easily develop CGI based applications in Pike. Note that this is probably your lowest performance option, as each request to the CGI will include the time required to start the Pike interpreter, as well as the time required to compile the application. If at all possible, it's better to use one of the persistent options below.


The {link:Public.Web.FCGI|} module allows users to easily write applications for use with web servers that support {link:FastCGI|}. This module uses the libfcgi library to provide excellent cross-server support.


The ScriptRunner application (see below) contains code for providing application services using the {link:SCGI|} protocol. This protocol support can be adapted to your own needs fairly readily.


Pike includes support for building web servers within a Pike process. For simple needs, or highly specialized needs, this may be the way to go. See how to create a web server in pike by viewing [PikeDevel/HowTo/Simple Web Server].

__Frameworks and Application Servers__


[PikeApps/Pike ScriptRunner] is a FastCGI/SCGI application that allows you to run Pike and PSP (Pike Server Pages) scripts from any web server that supports FastCGI or SCGI.


{link:Fins|} is a web application framework that uses the MVC paradigm to build scalable, easily mantained applications. Similar in concept to Ruby on Rails, Fins offers powerful templating and data management functionality. Fins applications can be deployed via HTTP, FastCGI, SCGI or within Caudium.

~~Caudium / Roxen~~

{link:Caudium|} and {link:Roxen|} are both webservers written in Pike. However, they offer extendability and program development options that make them much more than just web servers. Built in Pike scripting and languages like RXML make rapid application development possible, even for non-programmers. The ability to add and update modules that extend and enhance server functionality on the fly, without restarts, makes these servers very powerful. 

__What about mod_pike?__

While it's fair to say that mod_perl and mod_php are extremely popular solution for making a language available within a web server, the convenience does come at a high price. Stability, security and administrative headaches are some of the reasons to avoid embedded interpreters. The perceived performance advantages of using embedded interpreters mostly disappear when compared with persistent language engines, like ScriptRunner.

Persistent applications using protocols like FastCGI, SCGI or AJP provide the high performance of embedded interpreters without the associated risks. Depending on the approach you ultimately take, there may be some headache surrounding application process startup, but the benefits will quickly outweigh any trade-offs.

__Coexisting with another Webserver__

Because of Pike's strong internet protocol support, many tools listed above provide a HTTP interface. Sometimes, that's not the most ideal situation, as there's often a web server installed already.

The easiest way is to use mod_proxy on Apache, or the functional equivalent. This allows you to proxy any part of a server's virtual filesystem to another server that speaks HTTP.

{link:AJP 1.3|} is a cross-application server protocol that can be used to provide access to a Caudium server from within any Webserver that has an AJP connector (such as mod_jk in Apache). One advantage of this is that mod_jk2 can selectively pass requests based on extension, so for example, you can use Caudium to process .pike files. To enable AJP 1.3 on a Caudium virtual server, simply create a new port that uses the "ajp13" protocol. A second advantage is that you can get load balancing by providing multiple backend Caudium servers and configure mod_jk to use them.

Powered by PikeWiki2 | Copyright © 2004 - 2009 | Pike is a trademark of Department of Computer and Information Science, Linköping University