in reply to thinking about mod_perl

If you need some hype^H^H^H^Hreasons why mod_perl is better than vanilla Apache and perl, check out the PHP documentation, and s/PHP/mod_perl/; technically this is all bunk, since mod_perl (and PHP) still uses the common gateway interface just like a vanilla Apache/perl installation does, but it manages to convince a lot of people that PHP is better than Perl, so it ought to work just as well at explaining the superiority of mod_perl.


Quidquid latine dictum sit altum viditur.

Replies are listed 'Best First'.
Re: Re: thinking about mod_perl
by tilly (Archbishop) on Jul 19, 2003 at 18:23 UTC
    A technical nit, mod_perl does not use the common gateway interface.

    If there is a resemblance, it is because the common gateway interface was designed based on the structure of an http request, and the commonalities between what a mod_perl job has to do and a CGI script have been intentionally exploited by the mod_perl people to make mod_perl easier to get into.

    Also note that mod_perl gives access to phases of Apache's handling of an http request that PHP does not and CGI cannot. (This is both good and bad - ISPs are more inclined to give people PHP rights on servers than mod_perl because the latter is harder to restrict.)

      mod_perl does not use the common gateway interface

      I realise the backend is implemented differently on the server side, but the interface between the browser and the server is the same. It has to be; if it weren't, it wouldn't work without special browser support. The same is true of PHP. This is what makes the gateway interface common, is it not?


      Quidquid latine dictum sit altum viditur.
        The browser and server talk HTTP = Hyper Text Transport Protocol. The word Gateway in CGI refers to it being a way to hook up the webserver with anything else that you want.

        In other words the CGI protocol refers only to what is happening on your server.

        PS My apologies for responding late. I am on the road and so do not have reliable net access.

Re: Re: thinking about mod_perl
by liz (Monsignor) on Jul 19, 2003 at 18:33 UTC
    "still uses the common gateway interface" is true in itself, but definitely not the complete truth.

    With mod_perl you can have complete control over the handling of a request, allowing to forego the setting up of environment variables that are part of the CGI specification. Instead of environment variables, you have methods that can be called on a number of objects, representing the request, the connection, the configuration of the Apache server, etc,

    And since there is no external program being called, there is no concept of piping information to/from that program (as specified in the Common Gateway Interface). Although stdout is usually tied to what will be sent to the browser.

    The handling of the request can go pretty far: in mod_perl 2 it is even possible to have piece of Perl code executed before the connection is completed. This allows you to bar bad visitors from using any of your servers' resources, e.g. depending on IP-number.

    Liz