mirror of
https://github.com/php/php-src.git
synced 2024-10-21 00:12:34 +00:00
8154dbb7a2
variable tunings and the new command line usage.
92 lines
3.4 KiB
Plaintext
92 lines
3.4 KiB
Plaintext
FastCGI module
|
|
--------------
|
|
|
|
This module requires the FastCGI development kit, available from
|
|
http://www.fastcgi.com/
|
|
|
|
Before building PHP, please enter the dev kit, and run:
|
|
|
|
./configure
|
|
make
|
|
make export
|
|
|
|
This will compile the library code required for the FastCGI module. All
|
|
that is then required is to configure PHP with the '--with-fastcgi' option.
|
|
After making the code, you will end up with a binary file called 'php'.
|
|
Installation of this file will depend on the web server being used, please
|
|
see their documentation for details.
|
|
|
|
|
|
|
|
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 a port
|
|
number to listen to on the command line, e.g.:
|
|
|
|
./php 8002
|
|
|
|
(you can also specify a bind address, e.g. ./php localhost:8002. However, this
|
|
relies on the FastCGI devkit and does not seem to work properly)
|
|
|
|
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!
|
|
|
|
|
|
Security
|
|
--------
|
|
|
|
Be sure to run the php binary as an appropriate userid. Also, firewall out
|
|
the port that PHP is listening on. In addition, you can set the environment
|
|
variable FCGI_WEB_SERVER_ADDRS to control who can connect to the FastCGI.
|
|
Set it to a comma separated list of IP addresses, e.g.:
|
|
|
|
export FCGI_WEB_SERVER_ADDRS=199.170.183.28,199.170.183.71
|
|
|
|
|
|
Tuning
|
|
------
|
|
|
|
There are a few tuning parameters that can be tweaked to control the
|
|
performance of FastCGI PHP. The following are environment variables that can
|
|
be set before running the PHP binary:
|
|
|
|
PHP_FCGI_CHILDREN (default value: 8)
|
|
|
|
This controls how many child processes the PHP process spawns. When the
|
|
fastcgi starts, it creates a number of child processes which handle one
|
|
page request at a time. So by default, you will be able to handle 8
|
|
concurrent PHP page requests. Further requests will be queued.
|
|
Increasing this number will allow for better concurrency, especially if you
|
|
have pages that take a significant time to create, or supply a lot of data
|
|
(e.g. downloading huge files via PHP). On the other hand, having more
|
|
processes running will use more RAM, and letting too many PHP pages be
|
|
generated concurrently will mean that each request will be slow.
|
|
|
|
PHP_FCGI_MAX_REQUESTS (default value: 500)
|
|
|
|
This controls how many requests each child process will handle before
|
|
exitting. When one process exits, another will be created. This tuning is
|
|
necessary because several PHP functions are known to have memory leaks. If the
|
|
PHP processes were left around forever, they would be become very inefficient.
|