php-cgi 5.3.x and APC 3.1.3

Joe Auty joe at netmusician.org
Sat May 8 09:06:59 UTC 2010


Michael Powell wrote:
> Joe Auty wrote:
>
>   
>> Hello,
>>
>> I'm trying to get the APC user cache to work for me... It works with PHP
>> installed as an Apache module, but not as a CGI.
>>     
>
> I run Apache with the event mpm. This may, or may not be wise, but I've been 
> doing it for a while now and had no problems with it. I also use Xcache so 
> my comments are not APC specific.
>
> Since not all of PHP is considered thread safe it is not advisable to run 
> PHP on the event mpm as it is a threaded version. The way around this is to 
> not use mod_php but instead run mod_fcgid.so so PHP can be run as a FastCGI.
>  
>   
The problem with mod_fcgid for me is that it doesn't work with the APC
cache... From
http://www.brandonturner.net/blog/2009/07/fastcgi_with_php_opcode_cache/ :

> Both mod_fcgid and mod_fastcgi can be told to limit the number of PHP
> processes to 1 per user. The PHP process can then be told how many
> children to spawn. Unfortunately mod_fcgid will only send one request
> per child process. The fact that PHP spawns its own children is
> ignored by mod_fcgid. If we use mod_fcgid with our setup, we can only
> handle one concurrent PHP request. This is not good. A long running
> request could easily block multiple smaller requests.



>> I understand that in order to get this to work one has to add a:
>>
>>     
>>> FastCgiConfig -maxClassProcesses 1
>>>       
>> to their Apache config (for those that use Apache). I've done this, but
>> I'm still not seeing any evidence that the user cache is working.
>>     
>
> This I do not know about and have never seen, but I do recall floundering 
> around in the beginning and being very confused by the difference between 
> exec'ing PHP code as a CGI as opposed to running it in a FastCGI process. 
> There is a huge difference, with the FastCGI being many times faster. 
>  
>   

I'm now convinced that FastCGI is running since I'm seeing FastCGI
signatures in my logs... I think I've been able to get everything to
work though, but I can see why this article above says that performance
of what I'm doing (upload progress bar) is not as good. Oh well, I
imagine that the general improvements in using FastCGI and PHP CGI will
offset this difference.

More below...

>
> In phpinfo(); you can see this:
>
> Server API 	CGI/FastCGI 
>
>   
I'm seeing that... Thanks for posting your example httpd.conf config, it
was useful to make sure I had all of my bases covered!


> My options for PHP build:
>
> WITH_CLI=true
> WITH_CGI=true
> WITH_APACHE=true
> WITHOUT_DEBUG=true
> WITH_SUHOSIN=true
> WITH_MULTIBYTE=true
> WITHOUT_IPV6=true
> WITHOUT_MAILHEAD=true
> WITH_REDIRECT=true
> WITH_DISCARD=true
> WITH_FASTCGI=true
> WITH_PATHINFO=true
>
> Also keep in mind that any time PHP is rebuilt APC will need to be rebuilt 
> too.
>
>   
Thanks! It looks like the with_fastcgi option has been removed from PHP
5.3's make config option list (no sign of it in the Makefile either),
but it appears that building with CGI support also builds it with
FastCGI support. I'm assuming this FastCGI support is generic and
supports both mod_fastcgi and mod_fcgi? This is the confusing part, I'm
sure someday I'll want to upgrade to mod_fcgi as soon as it supports the
APC (or some other) cache mechanism which I count on for upload progress
bars.

Thanks again for your help!


-- 
Joe Auty, NetMusician
NetMusician helps musicians, bands and artists create beautiful,
professional, custom designed, career-essential websites that are easy
to maintain and to integrate with popular social networks.
www.netmusician.org <http://www.netmusician.org>
joe at netmusician.org <mailto:joe at netmusician.org>



More information about the freebsd-questions mailing list