Link to home
Start Free TrialLog in
Avatar of Webstorm
Webstorm

asked on

PHP SCGI + FastCGI

Hi experts,

Where can I download the SCGI version and the FastCGI version of PHP for Windows ?
And how should I start it (command line options ...) ?

I'm developping a web server, and I already tried running PHP as CGI only, but it's a bit slow.
I already developped the SCGI interface, and will make the more complicated FastCGI interface later.
Avatar of Webstorm
Webstorm

ASKER

For the PHP SCGI version, i would like to know how to specify the port to listen, and the address to bind.
All of PHP can be downloaded from www.php.net

This is THE official repository of PHP.

You can also download the source to PHP here as well.

And yes, CGI is not ideal.

The php executable is automaticallly fastcgi (I think).

<03/04/2006  8:14:25 C:\>php-cgi -v
PHP 5.1.3-dev (cgi-fcgi) (built: Feb 20 2006 00:28:46)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
    with Zend Extension Manager v1.0.10, Copyright (c) 2003-2006, by Zend Technologies
    with Zend Optimizer v3.0.0-Beta2, Copyright (c) 1998-2006, by Zend Technologies


Ideally, the ISAPI interface is the best way to go for non IIS.

I'm a windows user and I've used Sambar Server with ISAPI module for nearly 5 years (PHP4 and PHP5). I've not had any problems with it.

And I've added the Zend Optimizer.

Very stable.

For me, the main disadvantage of using an executable (CGI/FCGI) is the lack of persistent database connections. This is VERY important if you have a DB orientated website.



Hi RQuadling,

Thanks for your suggestion but I can't use ISAPI because I'm using Java.

>> For me, the main disadvantage of using an executable (CGI/FCGI) is the lack of persistent database connections.
I understand this point for CGI. But FastCGI or SCGI executables are only started once, so persistent database connections should be possible.
Also the main advantage of using external executable is executable can crash without crashing the web server itself which can restart the executable when necessary.
OK. I'm unfamiliar with "SCGI". I don't recall ever seeing this SAPI.

But the binding bit. From the README.FastCGI file in phpsrc/sapi/cgi

Running the FastCGI PHP module
------------------------------

There are two ways to run the resulting 'php' binary after the fastcgi
version has been built:

1) Configure your web server to run the PHP binary itself.

This is the simplest method, obviously you will have to configure your
web server appropriately. Some web servers may also not support this method,
or may not be as efficient.

2) Run PHP separately from the web server.

In this setup, PHP is started as a separate process entirely from the web
server. It will listen on a socket for new FastCGI requests, and deliver
PHP pages as appropriate. This is the recommended way of running PHP-FastCGI.
To run this way, you must start the PHP binary running by giving it an IP
and a port number to listen to on the command line, e.g.:

    ./php -b 127.0.0.1:8002

The above line is the recommended way of running FastCGI.  You usually
want the FastCGI server to provide services to the localhost, not
everyone on the Internet.

If your web server sits on a remote host, you can make FastCGI listen
on all interfaces:

    ./php -b :8002
    ./php -b "*:8002"

Note that hostnames are not supported.

You must also configure your web server to connect to the appropriate port
in order to talk to the PHP FastCGI process.

The advantage of running PHP in this way is that it entirely separates the
web server and PHP process, so that one cannot disrupt the other. It also
allows PHP to be on an entirely separate machine from the web server if need
be, you could even have several web servers utilising the same running PHP
process if required!
ASKER CERTIFIED SOLUTION
Avatar of Richard Quadling
Richard Quadling
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
PHP doesn't still implements the SCGI interface ( http://python.ca/nas/scgi/protocol.txt ), so I have to use FastCGI.

Thanks for your help.