[Ilugc] Apache - PHP

  • From: rajasuperman@xxxxxxxxx (Raja Subramanian)
  • Date: Sat Aug 2 20:46:19 2008

On Fri, Aug 1, 2008 at 6:23 PM, Girish Venkatachalam
<girishvenkatachalam@xxxxxxxxx> wrote:

On 17:43:54 Aug 01, Kenneth Gonsalves wrote:

I dunno about php. But in python and perl there are two ways of doing a
website:

1. Use standard python and perl with the CGI module - put your scripts in
cgi-bin and apache invokes the python/perl interpreter to run the scripts -
slow.

To speed it up, you can use fastcgi or speedycgi for this.  The fastcgi
process manages many running instances of your perl/php/python interpreters
and communicates with apache through a socket.  No more slow downs.


2. Use mod_perl/mod_python which is embedded in apache as a module. Put
your scripts anywhere and apache runs them as a part of apache - fast. No
CGI here.


Okay now you make yourself clear.

This difference is not important.

There are subtle but important differences in running your interpreter inside
apache's address space when loaded as a module, and running as a
separate process through CGI/fastcgi:

First issue is thready safety.  If your interpreter is not thread safe, and
mod_php for one is not, then apache itself can't run in threaded mode.
Both apache and your interpreter need to agree on how they handle
threads.

Second, if you are virtual hosting, you will want to isolate code from the
various webs that you are hosting on a single apache instance.  You
can run each web in its own CGI/fastcgi process with complete isolation
from other webs.  Achieving isolation through the mod_* approach is
possible, but prone to exploits.  Nearly all hosting providers I've used run
cgi/fastcgi and not mod_*.

Third, using the fastcgi approach, apache and fastcgi don't need to run
on the same physical machine.  Fastcgi can run on separate machines
optimized for generating the dynamic content while apache servers can
be on hardware tuned for content delivery/serving.  Fastcgi offers greater
flexibility when you need to scale up.

- Raja

Other related posts: