You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
4.2 KiB

  1. Using PHP 5 with the Zeus Web Server
  2. -----------------------------------
  3. Zeus fully supports running PHP in combination with our
  4. webserver. There are three different interfaces that can be used to
  5. enable PHP:
  6. * CGI
  7. * ISAPI
  8. * FastCGI
  9. Of the three, we recommend using FastCGI, which has been tested and
  10. benchmarked as providing the best performance and reliability.
  11. Full details of how to install PHP are available from our
  12. website, at:
  13. http://support.zeus.com/products/php.html
  14. If you have any problems, please check the support site for more
  15. up-to-date information and advice.
  16. Quick guide to installing CGI/FastCGI with Zeus
  17. -----------------------------------------------
  18. Step 1 - Compile PHP as FastCGI.
  19. Compile as follows:
  20. ./configure --enable-fastcgi
  21. make
  22. Note that PHP has many options to the configure script -
  23. e.g. --with-mysql. You will probably want to select your usual options
  24. before compiling; the above is just a bare minimum, for illustration.
  25. After compilation finishes, you will be left with an executable
  26. program called 'php'. Copy this into your document root, under a
  27. dedicated FastCGI directory (e.g. $DOCROOT/fcgi-bin/php)
  28. Step 2 - configure Zeus
  29. Four stages:
  30. - enable FastCGI
  31. - configure FastCGI
  32. - setup alias for FastCGI
  33. - setup alias for PHP
  34. 1) Using the admin server, go to the 'module configuration' page for
  35. your virtual server, and ensure that 'fastcgi' is enabled (select the
  36. tickbox to the left).
  37. 2) While we can run FastCGI's locally, there are known problems with
  38. some OS's (specifically, the communication between web server and
  39. FastCGI happens over a unix domain socket, and some OS's have trouble
  40. sustaining high connection rates over these sockets). So instead, we
  41. are going to set up the PHP FastCGI to run 'remotely' over localhost
  42. (this uses TCP sockets, which do not suffer this problem). Go to the
  43. 'fastcgi configuration' page, and under 'add remote fastcgi':
  44. Add Remote FastCGI
  45. Docroot path /fcgi-bin/php
  46. Remote machine localhost:8002
  47. The first entry is where you saved PHP, above.
  48. The second entry is localhost:<any unused port>
  49. We will start the FastCGI listening on this port shortly.
  50. Click 'update' to commit these changes.
  51. 3) Go to the path mapping module and add an alias for FastCGI:
  52. Add Alias
  53. Docroot path /fcgi-bin
  54. Filesystem directory /path/to/docroot/fcgi-bin
  55. Alias type fastcgi
  56. Click 'update' to commit these changes
  57. 4) Also on the path mapping module, add a handler for PHP:
  58. Add handler
  59. File extension php
  60. Handler /fcgi-bin/php
  61. Click 'update' to commit these changes
  62. Finally restart your virtual server for these changes to take effect.
  63. Step 3 - start PHP as a FastCGI runner
  64. When you start PHP, it will pre-fork a given number of child processes
  65. to handle incoming PHP requests. Each process will handle a given
  66. number of requests before exiting (and being replaced by a newly
  67. forked process). You can control these two parameters by setting the
  68. following environment variables BEFORE starting the FastCGI runner:
  69. PHP_FCGI_CHILDREN - the number of child processes to pre-fork. This
  70. variable MUST be set, if not then the PHP will not run as a FastCGI.
  71. We recommend a value of 8 for a fairly busy site. If you have many,
  72. long-running PHP scripts, then you may need to increase this further.
  73. PHP_FCGI_MAX_REQUESTS - the number of requests each PHP child process
  74. handles before exiting. If not set, defaults to 500.
  75. To start the FastCGI runner, execute '$ZEUSHOME/web/bin/fcgirunner
  76. 8002 $DOCROOT/fcgi-bin/php'. Substitute the appropriate values for
  77. $ZEUSHOME and $DOCROOT; also substitute for 8002 the port you chose,
  78. above.
  79. To stop the runner (e.g. to experiment with the above environment
  80. variables) you will need to manually stop and running PHP
  81. processes. (Use 'ps' and 'kill'). As it is PHP which is forking lots
  82. of children and not the runner, Zeus unfortunately cannot keep track
  83. of what processes are running, sorry. A typical command line may look
  84. like 'ps -efl | grep $DOCROOT/fcgi-bin/php | grep -v grep | awk
  85. '{print $4}' | xargs kill'