You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Hajo Locke <ha...@gmx.de> on 2010/07/27 11:43:01 UTC

[users@httpd] Re: recommended setup apache/php

>> PHP in CGI mode consumes lot of memory because, for every request a
>> PHP interpreter is called up, so your memory is filled with N php
>> interpreters executing the same PHP code where N is the number of
>> online users.
>> There is no way to avoid it except using some different method like
>> fastcgi/mod_php.
>>
>> FastCgi (also fcgid, its the same thing) is better as compared to
>> mod_php, because it gives more security i.e. the PHP interpreter is
>> not embedded into apache, php interpreter runs separately.
>> The PHP interpreter once started isn't killed by mod_{fastcgi,fcgid}
>> on the end of request as in CGI, but that is configurable.
>> Once a request finishes, the PHP interpreter keeps running, and as
>> soon as another request is received, the running PHP interpreter is
>> used to process the PHP file.
>> So there's no overhead of initiating the process again and again.
>> Also, mod_fcgid (not mod_fastcgi) caches the compiled code in memory,
>> so you don't need opcode caching mechanisms to accelerate PHP
>> performance like (eaccelerator, xcache, etc.) - reduces the memory
>> used by those extensions.

>> I personally use mod_fcgid on my server and am happy with it. It gives
>> stunning performance.

>> You should try out mod_fcgid.

sounds good. did some tests with mod_fcgid. cpu-load is higher then using 
mod_php but not as high as expected.
is this the way how it the big ones do?
is it possible to show your config?

there is one sentences in the docs which sounds strange
###
Warning
Currently, only one FastCGI application of any type (AAA or handler) can be 
used for a particular request URI. Otherwise, the wrong FastCGI application 
may be invoked for one or more phases of request processing.
###
this means that only on fcgid-script per location is possible? i would like 
to have .php4 files bind to a php4-wrapper and .php5 files bind to a 
php5-wrapper in same directory. i did some tests but could not confirm or 
decline.

Thanks,
Hajo






---------------------------------------------------------------------
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] Re: recommended setup apache/php

Posted by Nilesh Govindarajan <li...@itech7.com>.
On Tue, Jul 27, 2010 at 5:26 PM, Jefferson Ogata <ap...@antibozo.net> wrote:
> On 2010-07-27 10:15, Nilesh Govindarajan wrote:
>> If I understood your question properly, you're asking that
>> /htdocs/a.php is one fastcgi app and /htdocs/b.php is another.
>> If you want it this way, then you will have to add the shebang (#!)
>> line to all of your scripts before <?php starts, which is not a viable
>> solution if you have many php scripts which directly interact with the
>> public.
>>
>> I don't use that method, see my config below. .php is processed
>> without any shebang stuff.
>>
>> FcgidMaxProcesses 100
>> FcgidMaxProcessesPerClass 50
>> FcgidFixPathInfo 1
>> FcgidPassHeader HTTP_AUTHORIZATION
>> FcgidMaxRequestsPerProcess 100
>> FcgidOutputBufferSize 1048576
>> FcgidProcessLifeTime 60
>> FcgidMinProcessesPerClass 0
>> FcgidIOTimeout 120
>>
>> ExpiresActive On
>> ExpiresDefault "access plus 1 month"
>>
>> # This config below ensures that php is processed w/o presence of shebang line
>>
>> DirectoryIndex index.html index.php
>> AddType text/html .php
>> AddHandler php-fastcgi .php
>> Action php-fastcgi /cgi-bin/php.fcgi
>>
>> <FilesMatch "\.php$">
>>         Options +ExecCGI
>>         ExpiresActive Off
>> </FilesMatch>
>>
>> And the source code for /cgi-bin/php.fcgi:
>>
>> #!/bin/bash
>> export PHPRC=/usr/local/etc/php PHP_FCGI_CHILDREN=0
>> exec /usr/local/bin/php-cgi $@
>
> I wouldn't put that in your /cgi-bin if I were you, or anywhere it could
> be invoked directly. It looks unsafe.
>
> ---------------------------------------------------------------------
> 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
>
>

Well it doesn't seem to work that way, see this-
http://www.itech7.com/cgi-bin/php.fcgi

-- 
Regards,
Nilesh Govindarajan
Facebook: http://www.facebook.com/nilesh.gr
Twitter: http://twitter.com/nileshgr
Website: http://www.itech7.com
VPS Hosting: http://www.itech7.com/a/vps

---------------------------------------------------------------------
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] Re: recommended setup apache/php

Posted by Jefferson Ogata <ap...@antibozo.net>.
On 2010-07-27 10:15, Nilesh Govindarajan wrote:
> If I understood your question properly, you're asking that
> /htdocs/a.php is one fastcgi app and /htdocs/b.php is another.
> If you want it this way, then you will have to add the shebang (#!)
> line to all of your scripts before <?php starts, which is not a viable
> solution if you have many php scripts which directly interact with the
> public.
> 
> I don't use that method, see my config below. .php is processed
> without any shebang stuff.
> 
> FcgidMaxProcesses 100
> FcgidMaxProcessesPerClass 50
> FcgidFixPathInfo 1
> FcgidPassHeader HTTP_AUTHORIZATION
> FcgidMaxRequestsPerProcess 100
> FcgidOutputBufferSize 1048576
> FcgidProcessLifeTime 60
> FcgidMinProcessesPerClass 0
> FcgidIOTimeout 120
> 
> ExpiresActive On
> ExpiresDefault "access plus 1 month"
> 
> # This config below ensures that php is processed w/o presence of shebang line
> 
> DirectoryIndex index.html index.php
> AddType text/html .php
> AddHandler php-fastcgi .php
> Action php-fastcgi /cgi-bin/php.fcgi
> 
> <FilesMatch "\.php$">
>         Options +ExecCGI
>         ExpiresActive Off
> </FilesMatch>
> 
> And the source code for /cgi-bin/php.fcgi:
> 
> #!/bin/bash
> export PHPRC=/usr/local/etc/php PHP_FCGI_CHILDREN=0
> exec /usr/local/bin/php-cgi $@

I wouldn't put that in your /cgi-bin if I were you, or anywhere it could
be invoked directly. It looks unsafe.

---------------------------------------------------------------------
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] Re: recommended setup apache/php

Posted by Nilesh Govindarajan <li...@itech7.com>.
If I understood your question properly, you're asking that
/htdocs/a.php is one fastcgi app and /htdocs/b.php is another.
If you want it this way, then you will have to add the shebang (#!)
line to all of your scripts before <?php starts, which is not a viable
solution if you have many php scripts which directly interact with the
public.

I don't use that method, see my config below. .php is processed
without any shebang stuff.

FcgidMaxProcesses 100
FcgidMaxProcessesPerClass 50
FcgidFixPathInfo 1
FcgidPassHeader HTTP_AUTHORIZATION
FcgidMaxRequestsPerProcess 100
FcgidOutputBufferSize 1048576
FcgidProcessLifeTime 60
FcgidMinProcessesPerClass 0
FcgidIOTimeout 120

ExpiresActive On
ExpiresDefault "access plus 1 month"

# This config below ensures that php is processed w/o presence of shebang line

DirectoryIndex index.html index.php
AddType text/html .php
AddHandler php-fastcgi .php
Action php-fastcgi /cgi-bin/php.fcgi

<FilesMatch "\.php$">
        Options +ExecCGI
        ExpiresActive Off
</FilesMatch>

And the source code for /cgi-bin/php.fcgi:

#!/bin/bash
export PHPRC=/usr/local/etc/php PHP_FCGI_CHILDREN=0
exec /usr/local/bin/php-cgi $@

-- 
Regards,
Nilesh Govindarajan
Facebook: http://www.facebook.com/nilesh.gr
Twitter: http://twitter.com/nileshgr
Website: http://www.itech7.com
VPS Hosting: http://www.itech7.com/a/vps

---------------------------------------------------------------------
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] Re: recommended setup apache/php

Posted by Jonas Eckerman <jo...@frukt.org>.
On 2010-07-27 11:43, Hajo Locke wrote:

> there is one sentences in the docs which sounds strange

In what way does it seem strange?

> Currently, only one FastCGI application of any type (AAA or handler) can
> be used for a particular request URI.

[...]

> this means that only on fcgid-script per location is possible?

Depends on what *you* mean by "location". It says only one fcgid
application per *uri*.

> like to have .php4 files bind to a php4-wrapper and .php5 files bind to
> a php5-wrapper in same directory.

That should work fine. A URI ending in ".php4" is not the same URI as
one ending in ".php5".

Regards
/Jonas
-- 
Jonas Eckerman
Fruktträdet & Förbundet Sveriges Dövblinda
http://www.fsdb.org/
http://www.frukt.org/
http://whatever.frukt.org/

---------------------------------------------------------------------
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