Re: PHP and a general problem understanding fastcgi

David Birnbaum <[email protected]>
Newsgroups gmane.comp.web.fastcgi.devel
Message-ID <[email protected]>
We use php/FastCGI extensively - it's great for a number of reasons:

1.  You can control the number of instances of PHP per vhost very 
easily, which prevents CPU thrash.
2.  The memory usage of the server is reduced because httpd stays very 
light.
3.  Each PHP instance runs as the correct user/group which reduces 
security exposure.

Our bench testing shows straight PHP is about the same in other mod_php 
or FastCGI.  However, I find overall web performance to be slightly 
higher because plenty of httpd's stay uninvolved with PHP and can handle 
images/static pages while the PHP instances crunch away independently.

Here's a sample vhost configuration for you:

  User blah
  Group blahgrp
  FastCgiServer /export/httpd/DOMAINS/blah.com/cgi-bin/php -port 9050
  AddHandler php-fastcgi .php
  <Location /cgi-bin/php>
    SetHandler fastcgi-script
  </Location>
  Action php-fastcgi /cgi-bin/php

That creates the necessary hookup for .php files, and runs PHP stuff via 
suexec as blah/blahgrp.  You then have this file:

  #!/bin/sh
  PHPRC="/usr/local/etc/php/php-blah"
  export PHPRC

  PHP_FCGI_CHILDREN=4
  export PHP_FCGI_CHILDREN
  exec /opt/php/4.3.4/bin/php

which controls that particular instance.

Cheers,

David.

------------------------------------------------------------------------

Sylvain Becker wrote:

>Hi Benjamin,
>
>As you said, you should identify your needs first. I read that you are
>already working with PHP.
>Is your traffic website so heavy to explain moving to FastCGI ?
>Regards,
>
>Sylvain Becker
>
>On 7/11/05, Benjamin Podszun <ben-/[email protected]> wrote:
>  
>
>>Hi there.
>>
>>I'm lurking on this list for quite some time and read the docs on the
>>fastcgi.com site, but I'm still a little bit lost.
>>
>>On the one hand I'm still unsure if I want fastcgi in the first place
>>(read: Does it fit my needs..). Perhaps anyone can comment on whether
>>it's a good idea to start individual fastcgi servers for some vhosts
>>using different suexec wrapper, to enhance security and keep the
>>performance of mod_php?
>>
>>On the other hand I'm lost with regard to the fastcgi config syntax. I
>>understand that a static server is a kind of web-application that is
>>started at startup and respawned as neccessary, while a dynamic server
>>springs into life when the first request needs one - and that the latter
>>behaves according to the general FastCgiConfig settings.
>>
>>What I don't understand (and testing didn't provide much insight so far)
>>is, how I connect servers and requests. I understand the dynamic server
>>mechanism ("this extension is a fcgi application, start a dynamic
>>server"), but I don't understand the static one. How would I (is it even
>>possible..?) associate a static /var/www/myVhost/fcgi-bin/php with all
>>.php files for one vhost? I mean, is there a way to say "use server X
>>for the following doc types" or something along that lines?
>>
>>On a sitenote: I'm using different php accelerators/caches currently..
>>If anyone has encountered any problems/issues with (fast)cgi php and
>>that kind of software I'd be glad to hear about it..
>>
>>I apologize if the answers to my questions are obvious. I really tried
>>to read/fiddle around, but no luck so far. Any pointers, hints etc. are
>>appreciated.
>>
>>Regards,
>>Ben
>>___________________________________
>>fastcgi-developers mailing list
>>http://fastcgi.com/fastcgi-developers/
>>
>>    
>>
>
>
>  
>

___________________________________
fastcgi-developers mailing list
http://fastcgi.com/fastcgi-developers/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.