You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Julien Cigar <jc...@ulb.ac.be> on 2010/10/07 12:42:00 UTC

[users@httpd] switching from mod_fastcgi to mod_fcgid

Hello,

I would like to switch from mod_fastcgi to mod_fcgid.
In my current configuration I have something like:

-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-

jcigar@bebif cgi-bin % pwd
/usr/local/www/apache22/cgi-bin
jcigar@bebif cgi-bin % cat tapir-php-wrapper.fcgi
#!/bin/sh

PHPRC="/usr/local/etc/php.ini"
export PHPRC

PHP_FCGI_CHILDREN=3
export PHP_FCGI_CHILDREN

PHP_FCGI_MAX_REQUESTS=10000
export PHP_FCGI_MAX_REQUESTS

exec /usr/local/bin/php-cgi -b 127.0.0.1:5000

-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-

Every webapp runs under a dedicated user, so I'm using sudo -u ... to 
launch the PHP "wrapper", and then I'm using the FastCgiExternalServer 
directive of mod_fastcgi to "link" the php-cgi processes to Apache. I 
have something like this in my Apache configuration file:

-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-

FastCgiExternalServer 
/usr/local/www/apache22/cgi-bin/tapir-php-wrapper.fcgi -host 
127.0.0.1:5000 -idle-timeout 1800

Action php-fastcgi /cgi-bin/tapir-php-wrapper.fcgi

AddHandler php-fastcgi .php

-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-

The advantage of this configuration is that I can launch the process 
under a dedicated user without using mod_suexec (which has more 
constraints).

I wondered if there is a FastCgiExternalServer equivalent in mod_fcgid 
and also if mod_suexec is the only way in mod_fcgid to launch a PHP 
webapp under a dedicated user?

Thanks,
Julien

-- 
No trees were killed in the creation of this message.
However, many electrons were terribly inconvenienced.

Re: [users@httpd] switching from mod_fastcgi to mod_fcgid

Posted by Jeff Trawick <tr...@gmail.com>.
On Thu, Oct 7, 2010 at 8:07 AM, Julien Cigar <jc...@ulb.ac.be> wrote:
> I'm happy with mod_fastcgi in fact, but ~once a month I have to restart
> Apache because it doesn't respond to requests anymore (I get a "The
> connection was reset" in my browser) ... and I suspect that mod_fastcgi
> *could* be the cause of this (or mod_passenger)

A common cause of that with PHP is the FastCGI module sending requests
to PHP as it decides to exit on its ownt; unfortunately I don't see a
relevant directive for mod_fastcgi to have it stop sending requests
after a certain count; for mod_fcgid it is FcgidMaxRequestsPerProcess;
I guess you could make PHP_FCGI_MAX_REQUESTS unlimited or very large.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] switching from mod_fastcgi to mod_fcgid

Posted by Julien Cigar <jc...@ulb.ac.be>.
On 10/07/2010 13:34, Jeff Trawick wrote:
> On Thu, Oct 7, 2010 at 6:42 AM, Julien Cigar<jc...@ulb.ac.be>  wrote:
>> Hello,
>>
>> I would like to switch from mod_fastcgi to mod_fcgid.
>> In my current configuration I have something like:
>>
>> -%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-
>>
>> jcigar@bebif cgi-bin % pwd
>> /usr/local/www/apache22/cgi-bin
>> jcigar@bebif cgi-bin % cat tapir-php-wrapper.fcgi
>> #!/bin/sh
>>
>> PHPRC="/usr/local/etc/php.ini"
>> export PHPRC
>>
>> PHP_FCGI_CHILDREN=3
>> export PHP_FCGI_CHILDREN
>>
>> PHP_FCGI_MAX_REQUESTS=10000
>> export PHP_FCGI_MAX_REQUESTS
>>
>> exec /usr/local/bin/php-cgi -b 127.0.0.1:5000
>>
>> -%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-
>>
>> Every webapp runs under a dedicated user, so I'm using sudo -u ... to launch
>> the PHP "wrapper", and then I'm using the FastCgiExternalServer directive of
>> mod_fastcgi to "link" the php-cgi processes to Apache. I have something like
>> this in my Apache configuration file:
>>
>> -%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-
>>
>> FastCgiExternalServer /usr/local/www/apache22/cgi-bin/tapir-php-wrapper.fcgi
>> -host 127.0.0.1:5000 -idle-timeout 1800
>>
>> Action php-fastcgi /cgi-bin/tapir-php-wrapper.fcgi
>>
>> AddHandler php-fastcgi .php
>>
>> -%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-
>>
>> The advantage of this configuration is that I can launch the process under a
>> dedicated user without using mod_suexec (which has more constraints).
>>
>> I wondered if there is a FastCgiExternalServer equivalent in mod_fcgid and
>
> no
>
> long-term solution for externally managed FastCGI applications is
> mod_proxy_fcgi in future Apache 2.4

Yes, I plan to switch to mod_proxy_fcgi once Apache 2.4 is out (as I did 
with mod_jk -> mod_proxy_ajp)

>
> (or keep using mod_fastcgi)
>

I'm happy with mod_fastcgi in fact, but ~once a month I have to restart 
Apache because it doesn't respond to requests anymore (I get a "The 
connection was reset" in my browser) ... and I suspect that mod_fastcgi 
*could* be the cause of this (or mod_passenger)

>> also if mod_suexec is the only way in mod_fcgid to launch a PHP webapp under
>> a dedicated user?
>
> yes
>

That's what I thought ..

Thanks for your answer,
Julien

> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See<URL:http://httpd.apache.org/userslist.html>  for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>     "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>


-- 
No trees were killed in the creation of this message.
However, many electrons were terribly inconvenienced.

Re: [users@httpd] switching from mod_fastcgi to mod_fcgid

Posted by Jeff Trawick <tr...@gmail.com>.
On Thu, Oct 7, 2010 at 6:42 AM, Julien Cigar <jc...@ulb.ac.be> wrote:
> Hello,
>
> I would like to switch from mod_fastcgi to mod_fcgid.
> In my current configuration I have something like:
>
> -%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-
>
> jcigar@bebif cgi-bin % pwd
> /usr/local/www/apache22/cgi-bin
> jcigar@bebif cgi-bin % cat tapir-php-wrapper.fcgi
> #!/bin/sh
>
> PHPRC="/usr/local/etc/php.ini"
> export PHPRC
>
> PHP_FCGI_CHILDREN=3
> export PHP_FCGI_CHILDREN
>
> PHP_FCGI_MAX_REQUESTS=10000
> export PHP_FCGI_MAX_REQUESTS
>
> exec /usr/local/bin/php-cgi -b 127.0.0.1:5000
>
> -%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-
>
> Every webapp runs under a dedicated user, so I'm using sudo -u ... to launch
> the PHP "wrapper", and then I'm using the FastCgiExternalServer directive of
> mod_fastcgi to "link" the php-cgi processes to Apache. I have something like
> this in my Apache configuration file:
>
> -%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-
>
> FastCgiExternalServer /usr/local/www/apache22/cgi-bin/tapir-php-wrapper.fcgi
> -host 127.0.0.1:5000 -idle-timeout 1800
>
> Action php-fastcgi /cgi-bin/tapir-php-wrapper.fcgi
>
> AddHandler php-fastcgi .php
>
> -%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-%-
>
> The advantage of this configuration is that I can launch the process under a
> dedicated user without using mod_suexec (which has more constraints).
>
> I wondered if there is a FastCgiExternalServer equivalent in mod_fcgid and

no

long-term solution for externally managed FastCGI applications is
mod_proxy_fcgi in future Apache 2.4

(or keep using mod_fastcgi)

> also if mod_suexec is the only way in mod_fcgid to launch a PHP webapp under
> a dedicated user?

yes

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org