| 1 |
== link:index.html[Index] -> link:cookbook.html[Cookbook] |
|---|
| 2 |
|
|---|
| 3 |
Cookbook: Setting up PHP |
|---|
| 4 |
------------------------ |
|---|
| 5 |
|
|---|
| 6 |
There is not much to learn to configure PHP with Cherokee. |
|---|
| 7 |
The default configuration (the one created by `cherokee-admin` from |
|---|
| 8 |
scratch when there is no `cherokee.conf` present) already supports |
|---|
| 9 |
PHP. |
|---|
| 10 |
|
|---|
| 11 |
This example shows a typical usage of FastCGI. It only uses one |
|---|
| 12 |
link:config_info_sources.html[information source] nicknamed `php` in |
|---|
| 13 |
this case. This connects to a FastCGI server located in localhost in |
|---|
| 14 |
port 1234. If no server is running, the webserver will run the FastCGI |
|---|
| 15 |
server by issuing the command defined as the *Interpreter* |
|---|
| 16 |
sub-parameter: |
|---|
| 17 |
|
|---|
| 18 |
image::media/images/admin_handler_fastcgi1.png[Fastcgi] |
|---|
| 19 |
|
|---|
| 20 |
This other example shows a typical usage of multiple FastCGI |
|---|
| 21 |
servers. It connects to FastCGI servers in several locations. If no |
|---|
| 22 |
server is running in the local computer, the webserver will run the |
|---|
| 23 |
FastCGI server by issuing the specified command. Note that for *remote* |
|---|
| 24 |
FastCGI servers, you are responsible of running the FastCGI services |
|---|
| 25 |
there manually: |
|---|
| 26 |
|
|---|
| 27 |
image::media/images/admin_handler_fastcgi2.png[Fastcgi] |
|---|
| 28 |
|
|---|
| 29 |
The **PHP_FCGI_CHILDREN** environment variable is mandatory for PHP |
|---|
| 30 |
FastCGI servers. It defines how much children should serve the |
|---|
| 31 |
requests coming from the webserver. |
|---|
| 32 |
|
|---|
| 33 |
If you define **PHP_FCGI_MAX_REQUESTS**, the value must be negative if |
|---|
| 34 |
you do not want the PHP process to ever be restarted. If you leave it |
|---|
| 35 |
unset, PHP will take the default value (500), after which it will be |
|---|
| 36 |
restarted. It is generally a good idea to let PHP be restarted to free |
|---|
| 37 |
up resources and possible memory leaks. |
|---|
| 38 |
|
|---|
| 39 |
Note that only FastCGI-enabled binaries of PHP will work with the |
|---|
| 40 |
FastCGI handler. Many prepackaged versions already enable this by |
|---|
| 41 |
default. If yours does not, you will need to build a suitable |
|---|
| 42 |
binary. You can check this with the `-v` parameter: |
|---|
| 43 |
|
|---|
| 44 |
---- |
|---|
| 45 |
$ php-cgi -v |
|---|
| 46 |
PHP 5.2.5 (cgi-fcgi) (built: Apr 20 2008 17:11:05) |
|---|
| 47 |
Copyright (c) 1997-2007 The PHP Group |
|---|
| 48 |
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies |
|---|
| 49 |
---- |
|---|
| 50 |
|
|---|
| 51 |
You cannot proceed unless the *"cgi-fcgi"* string is present. |
|---|