Franco Marchesini | 1 Mar 2005 09:01

Re: FastCGI for Delphi developers/freepascal

Lars wrote:

> Hello, I've searched the archives for information on implementing
> fastCGI for Delphi/Kylix/freepascal.
> I could not find anything thorough, so I wondered if Delphi
> developers wanted to gather together and work on the project?
> Instead of us individually searching and looking for answers I think
> we should combine forces.
> 
> If anyone knows of any basic info on pascal implementation or some
> real world examples let me know. Otherwise, I'll start hackign away
> at it.
> 
> Lars

Try
http://www.freepascal.org/contrib/db.php3?category=Internet
and download fcgipas

Ciao
Franco

___________________________________
fastcgi-developers mailing list
http://fastcgi.com/fastcgi-developers/
Aharoni Nir | 1 Mar 2005 14:34
Favicon

Apache 2.0.46,Fast Cgi and multi thread


Hello Folks,

I am running under apache 2.0.46 and my application is a C++ program compile as Fast Cgi (2.4.0).

Apache is configured to work as Multi Process (PreFork)

I would like to run apache with 1 process and multi threaded using worker module.

What I need to do in order to run my application as multi threaded?

Any special adaptations?




___________________________________
fastcgi-developers mailing list
http://fastcgi.com/fastcgi-developers/
Jason Pump | 2 Mar 2005 22:40
Favicon

RE: fastcgi+php=lots of 500 errors ?

What OS are you running on?

Have you checked that PHP is not running out of memory, or modifying php.ini
to allow more memory for the process to see how that effects the situation?

Jason

> -----Original Message-----
> From: fastcgi-developers-bounces+jpump=looksmart.net@...
> [mailto:fastcgi-developers-bounces+jpump=looksmart.net@...
> et]On Behalf Of Gabriel Barazer
> Sent: Monday, February 28, 2005 12:26 PM
> To: Simon; fastcgi-developers@...
> Subject: Re: [FASTCGI] fastcgi+php=lots of 500 errors ?
>
>
> On Monday, February 28, 2005 9:17 PM CET,
> Simon <simon@...> wrote:
>
> > Is that the only error you see in your error log? when you see 200req
> > a sec is that all PHP? is it 200req/sec per server or on all 3?
> >
>
> excepted the normal info messages from fastcgi such as:
> [Mon Feb 28 21:20:09 2005] [warn] FastCGI: (dynamic) server
> "/usr/local/bin/php-fcgi/php.fcgi" (pid 31004) terminated by calling exit
> with status '0'
>
> or
>
> [Mon Feb 28 21:20:09 2005] [warn] FastCGI: (dynamic) server
> "/usr/local/bin/php-fcgi/php.fcgi" (pid 31417) termination signaled
>
>
> or even
>
> [Mon Feb 28 21:20:09 2005] [warn] FastCGI: (dynamic) server
> "/usr/local/bin/php-fcgi/php.fcgi" (uid 522, gid 100) started (pid 31533)
>
> which are normal info message about fastcgi activity, yes , this
> is the only
> real errors.
>
> The servers are 3 pentium 4 3.2Ghz and it is 200req/s on all 3. If they
> weren't 500's , the configuration was clean : lesser than load
> average of 1,
> and a maximum of 400req/s capacity on all 3 servers (benchmark
> results, and
> a load not higher than 5).
>
> No other debugging information... I think i'll become crazy soon...
>
> BTW: i tested with the "stable" fastcgi version (2.4.2), and it
> produces the
> same result.
>
> --
> Gabriel Barazer <gabriel@...>
> REAGI
>
> >
> > On Mon, 28 Feb 2005 19:26:06 +0100, Gabriel Barazer wrote:
> >
> >> Hi,
> >>
> >> When using php with mod_fastcgi , i get a HUGE number of 500 errors
> >> and this line in the error log:
> >> FastCGI: incomplete headers (0 bytes) received from server
> >> "/usr/local/bin/php-fcgi/php.fcgi"
> >>
> >> I have a moderated traffic (~200req per second on 3 servers), and
> >> these 500's occurs 2-3 times per second on each server.
> >>
> >> My actual config is the same on both servers:
> >> ---
> >> FastCgiWrapper On
> >> FastCgiConfig -gainValue 0.8 -killInterval 5 -listen-queue-depth
> >> 512 -maxClassProcesses 96 -maxProcesses 192 -multiThreshold
> >> 60 -singleThreshold 1 -startDelay 1 -updateInterval 5
> >> ScriptAlias /fcgi-bin/ "/usr/local/bin/php-fcgi/"
> >> <Location /fcgi-bin/>
> >>        Options ExecCGI
> >>        SetHandler fastcgi-script
> >> </Location>
> >>
> >> AddHandler php-script .php .inc .pinc .phtml .php3 .php4
> >> Action php-script /fcgi-bin/php.fcgi
> >> ---
> >>
> >> It appears that if i raise the killinterval AND updateinterval, the
> >> number of errors decrease after a restart of apache, but as the
> >> uptime grows, the number of errors grows too...
> >>
> >> i haven't succeed to reproduce this bug as it seems to be very
> >> random (but it happens very more often when the traffic increases)
> >>
> >> Anyone have an idea about this *very* annoying effect ?
> >>
> >> Oh, i forgot to mention the software versions:
> >> apache 2.0.53
> >> php 4.3.10
> >> mod_fastcgi-snap-0404142202
> >>
> >> --
> >> Gabriel Barazer <gabriel@...>
> >> REAGI
>
> ___________________________________
> fastcgi-developers mailing list
> http://fastcgi.com/fastcgi-developers/
___________________________________
fastcgi-developers mailing list
http://fastcgi.com/fastcgi-developers/

Gabriel Barazer | 3 Mar 2005 11:21

Re: fastcgi+php=lots of 500 errors ?

On Wednesday, March 02, 2005 10:40 PM CET,
Jason Pump <JPump@...> wrote:

> What OS are you running on?
>

Linux kernel 2.6.10.

> Have you checked that PHP is not running out of memory, or modifying
> php.ini to allow more memory for the process to see how that effects
> the situation?
>

Yes, and it's not a memory problem. I finally solved the problem with 
mod_fcgid.

I think the problem was the timeout in the communication between mod_fastcgi 
and the php process. In the mod_fcgid, i got the IPCCommTimeout variable 
which has the desired effect (not returning a 500 when php take over 3 
seconds to respond). I've note found the same variable in mod_fastcgi.

What about adding this directive in fastcgi ?

In the next weeks, i will certainly attempt to code a fastcgi module 
designed for use with php and minimal configuration (but with the tuning 
stuff), inspired on the fastcgi and mod_fcgid code. I'll let know if this 
project becomes reality :)

So using mod_fcgid (+a suexec patch for my case) seems to work properly with 
php (with the very useful "wrapper" function): zero "500" errors since i've 
passed to this module.

Hope this maybe helps someone,

-- 
Gabriel Barazer <gabriel@...>
REAGI

>> -----Original Message-----
>> From:
>> fastcgi-developers-bounces+jpump=looksmart.net@...
>> [mailto:fastcgi-developers-bounces+jpump=looksmart.net@...
>> et]On Behalf Of Gabriel Barazer
>> Sent: Monday, February 28, 2005 12:26 PM
>> To: Simon; fastcgi-developers@...
>> Subject: Re: [FASTCGI] fastcgi+php=lots of 500 errors ?
>>
>>
>> On Monday, February 28, 2005 9:17 PM CET,
>> Simon <simon@...> wrote:
>>
>>> Is that the only error you see in your error log? when you see
>>> 200req a sec is that all PHP? is it 200req/sec per server or on all
>>> 3?
>>>
>>
>> excepted the normal info messages from fastcgi such as:
>> [Mon Feb 28 21:20:09 2005] [warn] FastCGI: (dynamic) server
>> "/usr/local/bin/php-fcgi/php.fcgi" (pid 31004) terminated by calling
>> exit with status '0'
>>
>> or
>>
>> [Mon Feb 28 21:20:09 2005] [warn] FastCGI: (dynamic) server
>> "/usr/local/bin/php-fcgi/php.fcgi" (pid 31417) termination signaled
>>
>>
>> or even
>>
>> [Mon Feb 28 21:20:09 2005] [warn] FastCGI: (dynamic) server
>> "/usr/local/bin/php-fcgi/php.fcgi" (uid 522, gid 100) started (pid
>> 31533)
>>
>> which are normal info message about fastcgi activity, yes , this
>> is the only
>> real errors.
>>
>> The servers are 3 pentium 4 3.2Ghz and it is 200req/s on all 3. If
>> they weren't 500's , the configuration was clean : lesser than load
>> average of 1,
>> and a maximum of 400req/s capacity on all 3 servers (benchmark
>> results, and
>> a load not higher than 5).
>>
>> No other debugging information... I think i'll become crazy soon...
>>
>> BTW: i tested with the "stable" fastcgi version (2.4.2), and it
>> produces the
>> same result.
>>
>> --
>> Gabriel Barazer <gabriel@...>
>> REAGI
>>
>>>
>>> On Mon, 28 Feb 2005 19:26:06 +0100, Gabriel Barazer wrote:
>>>
>>>> Hi,
>>>>
>>>> When using php with mod_fastcgi , i get a HUGE number of 500 errors
>>>> and this line in the error log:
>>>> FastCGI: incomplete headers (0 bytes) received from server
>>>> "/usr/local/bin/php-fcgi/php.fcgi"
>>>>
>>>> I have a moderated traffic (~200req per second on 3 servers), and
>>>> these 500's occurs 2-3 times per second on each server.
>>>>
>>>> My actual config is the same on both servers:
>>>> ---
>>>> FastCgiWrapper On
>>>> FastCgiConfig -gainValue 0.8 -killInterval 5 -listen-queue-depth
>>>> 512 -maxClassProcesses 96 -maxProcesses 192 -multiThreshold
>>>> 60 -singleThreshold 1 -startDelay 1 -updateInterval 5
>>>> ScriptAlias /fcgi-bin/ "/usr/local/bin/php-fcgi/"
>>>> <Location /fcgi-bin/>
>>>>        Options ExecCGI
>>>>        SetHandler fastcgi-script
>>>> </Location>
>>>>
>>>> AddHandler php-script .php .inc .pinc .phtml .php3 .php4
>>>> Action php-script /fcgi-bin/php.fcgi
>>>> ---
>>>>
>>>> It appears that if i raise the killinterval AND updateinterval, the
>>>> number of errors decrease after a restart of apache, but as the
>>>> uptime grows, the number of errors grows too...
>>>>
>>>> i haven't succeed to reproduce this bug as it seems to be very
>>>> random (but it happens very more often when the traffic increases)
>>>>
>>>> Anyone have an idea about this *very* annoying effect ?
>>>>
>>>> Oh, i forgot to mention the software versions:
>>>> apache 2.0.53
>>>> php 4.3.10
>>>> mod_fastcgi-snap-0404142202
>>>>
>>>> --
>>>> Gabriel Barazer <gabriel@...>
>>>> REAGI
>>
>> ___________________________________
>> fastcgi-developers mailing list
>> http://fastcgi.com/fastcgi-developers/ 

___________________________________
fastcgi-developers mailing list
http://fastcgi.com/fastcgi-developers/

Peter Colson | 4 Mar 2005 01:39
Picon
Favicon

Multi-threaded FastCGI servers

Hello,

I'm in the process of modifying a single-threaded FastCGI server. I'm 
trying to make the server multi-threaded by using Posix threads and the 
FastCGI API's in one of the two ways, as follows:

pcreate_thread(&AcceptThread, 0, (void*)&AcceptThreadFunc, 0);
...
AcceptThreadFunc(...)
{
     FCGX_Request FcgiReq;
     FCGX_InitRequest(&FcgiReq, 0, 0);
     while (FCGX_Accept_r(&FcgiReq) >= 0)
     {
         // Do the work.
     }
}

Or:

FCGX_Request FcgiReq;
FCGX_InitRequest(&FcgiReq, 0, 0);
while (FCGX_Accept_r(&FcgiReq) >= 0)
{
     pcreate_thread(&WorkerThread, 0, (void*)&WorkerThreadFunc, 0);
}
...
WorkerThreadFunc(...)
{
     // Do the work.
}

I have read that it is possible when using multi-threading in FastCGI 
to:

a). Put the entire accept loop into the worker thread, as in the first 
code segment (or the threaded.c example), or
b). Have just a single accept loop and put just the code within the 
accept loop into a worker thread.

Is this correct? If it is, option b) would imply just a single instance 
of an FCGX_Request variable meaning, in turn, that only one FcgiReq.out 
would ever be used/accessed by, say, FCGX_FPrintF/PutS. How is this 
different from just using FCGI_stdout in a single-threaded FCGI_Accept 
loop?

I understand that FCGI_Accept is not thread-safe, whereas FCGI_Accept_r 
is, but in option b) the accept loop is outside of the worker thread, 
so does it matter which accept API is used? I guess, it might if 
FCGI_fwrite, say, is not thread-safe, since that would be used in an 
FCGI_Accept loop, but not in a FCGX_Accept_r accept loop...

Basically, is either a) or b) a preferable solution? Is one better in 
some circumstances, but not others?

Regards,
Peter Colson.
___________________________________
fastcgi-developers mailing list
http://fastcgi.com/fastcgi-developers/
Miguel Saturnino | 8 Mar 2005 00:35
Picon

Apache, PHP, suexec and FastCGI

Hi all!

I'm trying to get PHP+SuExec+FastCGI to work with Apache (so that PHP
runs with the user's permissions and not the Web Server's permissions)
with no luck so far...

I've build Apache with suexec support, installed mod_fastgi and built
php as fast-cgi:

   root <at> furao # /usr/local/bin/phpfcgi -v
   PHP 4.3.10 (cgi-fcgi) (built: Mar  7 2005 20:49:09)
   Copyright (c) 1997-2004 The PHP Group
   Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies

My httpd.conf:

   (...) 
   LoadModule fastcgi_module     libexec/apache/mod_fastcgi.so
   (...) 
   AddModule mod_fastcgi.c
   (...)
   <VirtualHost test.pt>
      User miguel
      Group miguel
      ServerAdmin mags@...
      DocumentRoot /usr/home/miguel/httpdocs/test.pt
      ServerName test.pt
      ErrorLog logs/test.pt-error_log
      CustomLog logs/test.pt-access_log common
   </VirtualHost>

   FastCgiWrapper /usr/local/sbin/suexec
   FastCgiServer /usr/home/miguel/httpdocs/encontra-me.org/cgi-bin/php \
      -user www -group www
   AddHandler php-fastcgi .php
   <Location /cgi-bin/php>
      SetHandler fastcgi-script
   </Location>
   Action php-fastcgi /cgi-bin/php
   AddType application/x-httpd-php .php

root <at> furao # ls -l /home/miguel/httpdocs/encontra-me.org/cgi-bin/php
   -rwxr-xr-x  1 miguel  miguel  128  7 Mar 20:27 
    /home/miguel/httpdocs/encontra-me.org/cgi-bin/php

root <at> furao # more /home/miguel/httpdocs/encontra-me.org/cgi-bin/php
   #!/bin/sh
   PHPRC="/usr/local/etc/php.ini"
   export PHPRC
   PHP_FCGI_CHILDREN=4
   export PHP_FCGI_CHILDREN
   exec /usr/local/bin/phpfcgi

Apache error log:
root <at> furao # tail /var/log/httpd-error.log
   (...)
   [Mon Mar  7 23:10:45 2005] [notice] SIGUSR1 received.  Doing graceful
    restart
   Warning: User directive in <VirtualHost> requires SUEXEC wrapper.
   Warning: Group directive in <VirtualHost> requires SUEXEC wrapper.
   [Mon Mar  7 23:10:45 2005] [alert] httpd: Could not determine the server's
    fully qualified domain name, using 127.0.0.1 for ServerName
   [Mon Mar  7 23:10:45 2005] [notice] FastCGI: wrapper mechanism enabled
    (wrapper: /usr/local/sbin/suexec)
   [Mon Mar  7 23:10:45 2005] [notice] FastCGI: process manager initialized
    (pid 10101)
   [Mon Mar  7 23:10:46 2005] [notice] Apache/1.3.33 (Unix) mod_fastcgi/2.4.2
    configured -- resuming normal operations
   [Mon Mar  7 23:10:46 2005] [notice] Accept mutex: flock (Default: flock)

Now, when I try to access a PHP web page I get a 403 Forbiden Error (even if
the file doesn't exist) and the request URL is changed from abc.php to
/cgi-bin/php/abc.php. For example, if I try to acess http://test.pt/phpinfo.php
I get this error message:
   Not Found
   The requested URL /cgi-bin/php/phpinfo.php was not found on this
    server.
   Apache/1.3.33 Server at test.pt Port 80

What am I doing wrong?

TIA!

Regards,

--

-- 
Miguel Saturnino <mags@...>

___________________________________
fastcgi-developers mailing list
http://fastcgi.com/fastcgi-developers/
Miguel Saturnino | 8 Mar 2005 00:47
Picon

Re: Apache, PHP, suexec and FastCGI

On Mon, 2005-03-07 at 23:35 +0000, Miguel Saturnino wrote:
> I've build Apache with suexec support, installed mod_fastgi and built
> php as fast-cgi:
> 
>    root <at> furao # /usr/local/bin/phpfcgi -v
>    PHP 4.3.10 (cgi-fcgi) (built: Mar  7 2005 20:49:09)
>    Copyright (c) 1997-2004 The PHP Group
>    Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies
> 
> My httpd.conf:
> 
>    (...) 
>    LoadModule fastcgi_module     libexec/apache/mod_fastcgi.so
>    (...) 
>    AddModule mod_fastcgi.c
>    (...)
>    <VirtualHost test.pt>
>       User miguel
>       Group miguel
>       ServerAdmin mags@...
>       DocumentRoot /usr/home/miguel/httpdocs/test.pt
>       ServerName test.pt
>       ErrorLog logs/test.pt-error_log
>       CustomLog logs/test.pt-access_log common
>    </VirtualHost>
> 
>    FastCgiWrapper /usr/local/sbin/suexec
>    FastCgiServer /usr/home/miguel/httpdocs/encontra-me.org/cgi-bin/php \
>       -user www -group www
>    AddHandler php-fastcgi .php
>    <Location /cgi-bin/php>
>       SetHandler fastcgi-script
>    </Location>
>    Action php-fastcgi /cgi-bin/php
>    AddType application/x-httpd-php .php
> 
> 
> root <at> furao # ls -l /home/miguel/httpdocs/encontra-me.org/cgi-bin/php
>    -rwxr-xr-x  1 miguel  miguel  128  7 Mar 20:27 
>     /home/miguel/httpdocs/encontra-me.org/cgi-bin/php
> 
> root <at> furao # more /home/miguel/httpdocs/encontra-me.org/cgi-bin/php
>    #!/bin/sh
>    PHPRC="/usr/local/etc/php.ini"
>    export PHPRC
>    PHP_FCGI_CHILDREN=4
>    export PHP_FCGI_CHILDREN
>    exec /usr/local/bin/phpfcgi
> 
> 
> Apache error log:
> root <at> furao # tail /var/log/httpd-error.log
>    (...)
>    [Mon Mar  7 23:10:45 2005] [notice] SIGUSR1 received.  Doing graceful
>     restart
>    Warning: User directive in <VirtualHost> requires SUEXEC wrapper.
>    Warning: Group directive in <VirtualHost> requires SUEXEC wrapper.
>    [Mon Mar  7 23:10:45 2005] [alert] httpd: Could not determine the server's
>     fully qualified domain name, using 127.0.0.1 for ServerName
>    [Mon Mar  7 23:10:45 2005] [notice] FastCGI: wrapper mechanism enabled
>     (wrapper: /usr/local/sbin/suexec)
>    [Mon Mar  7 23:10:45 2005] [notice] FastCGI: process manager initialized
>     (pid 10101)
>    [Mon Mar  7 23:10:46 2005] [notice] Apache/1.3.33 (Unix) mod_fastcgi/2.4.2
>     configured -- resuming normal operations
>    [Mon Mar  7 23:10:46 2005] [notice] Accept mutex: flock (Default: flock)
> 
> 
> Now, when I try to access a PHP web page I get a 403 Forbiden Error (even if
> the file doesn't exist) and the request URL is changed from abc.php to
> /cgi-bin/php/abc.php. For example, if I try to acess http://test.pt/phpinfo.php
> I get this error message:
>    Not Found
>    The requested URL /cgi-bin/php/phpinfo.php was not found on this
>     server.
>    Apache/1.3.33 Server at test.pt Port 80
> 

Sorry, but where it reads "encontra-me.org" it should read "test.pt".

--

-- 
Miguel Saturnino <mags@...>

___________________________________
fastcgi-developers mailing list
http://fastcgi.com/fastcgi-developers/
Miguel Saturnino | 8 Mar 2005 00:49
Picon

Re: Apache, PHP, suexec and FastCGI

On Tue, 2005-03-08 at 00:40 +0100, Gabriel Barazer wrote:
> Have you compiled php with the "--enable-discard-path" option ? If so, you 
> must recompile your php binary as the protection implemented 
> with --enable-discard-path prevents fastcgi from working right. I spent a 
> couple hours before notifying that in my setup...
> 

Yes, I compiled PHP with --enable-discard-path, I'll compile it again
and see how it goes. Thanks!

Regards,

--

-- 
Miguel Saturnino <mags@...>

___________________________________
fastcgi-developers mailing list
http://fastcgi.com/fastcgi-developers/
Miguel Saturnino | 8 Mar 2005 00:59
Picon

Re: Apache, PHP, suexec and FastCGI

On Mon, 2005-03-07 at 23:49 +0000, Miguel Saturnino wrote:
> On Tue, 2005-03-08 at 00:40 +0100, Gabriel Barazer wrote:
> > Have you compiled php with the "--enable-discard-path" option ? If so, you 
> > must recompile your php binary as the protection implemented 
> > with --enable-discard-path prevents fastcgi from working right. I spent a 
> > couple hours before notifying that in my setup...
> > 
> 
> Yes, I compiled PHP with --enable-discard-path, I'll compile it again
> and see how it goes. Thanks!

Replying to myself, I've compiled PHP without --enable-discard-path but
the problem remains:

root <at> furao # /usr/local/bin/phpfcgi -v
   PHP 4.3.10 (cgi-fcgi) (built: Mar  7 2005 23:54:17)
   Copyright (c) 1997-2004 The PHP Group
   Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies

Regards,

--

-- 
Miguel Saturnino <mags@...>

___________________________________
fastcgi-developers mailing list
http://fastcgi.com/fastcgi-developers/
Miguel Saturnino | 8 Mar 2005 20:20
Picon

PHP as Suexec with Apache 1.3.33 and mod_fastcgi 2.4.2

Hi all!

I'm able to run PHP scripts with FastCGI but I still haven't figured out
how to run them using Suexec, so that they run with the user's
permissions. (If anyone has this kind of setup working I'd be grateful
if you'd share your httpd.conf with me!)

At http://www.fastcgi.com/docs/faq.html#PHP it says that one should "put
the PHP configuration information into the VirtualHost directive" but if
I get an error saying that FastCgiServer cannot occur within
VirtualHost:

root <at> furao # apachectl configtest
Syntax error on line 1084 of /usr/local/etc/apache/httpd.conf:
FastCgiServer cannot occur within <VirtualHost> section

Regards,

--

-- 
Miguel Saturnino <mags@...>

___________________________________
fastcgi-developers mailing list
http://fastcgi.com/fastcgi-developers/

Gmane