PHP: Hypertext PreprocessorContents
More resourcesPHP integration methods with Zeus Web ServerThere are a number of ways to integrate PHP with Zeus Web Server. Our preferred method is to use FastCGI with Remote Responders. A description of all the methods along with their advantages and disadvantages are discussed below.
Obtaining a copy of FastCGI/PHPChoose either to compile from source or use a pre-compiled binary.
Compiling and Installing FastCGI/PHPStep 1 - Compiling FastCGI/PHP from source. Extract the package and compile as follows:
You may want to pass additional options to the PHP configure script e.g. --with-mysql. The illustration above shows the minimum neccessary. Please consult the PHP documentation for more information regarding extra compile time options. Note:
After compilation finishes, you will be left with an executable program called php. The binary will be found in the sapi/cgi directory of your PHP installation directory. You may optionally want to execute the following command to install the php binary to /usr/local/bin
Step 2 - Testing the PHP binaryBefore configuring Zeus to use the PHP binary, it is neccessary to check that the binary has been built successfully. This can be done by testing that the binary can process PHP commands when run as a CGI. From the PHP installation sapi/cgi directory execute the following command:
Note: If you have a recent version of PHP, the binary may be called php-cgi. You will now need to type in the following:
Now signify the end of input with <ctrl-d> You should see a page of html displayed which is the output from the phpinfo() command. If this does not happen, consult the official PHP documentation from either the PHP installation directory or from the PHP website Configuring Zeus Web Server to use FastCGI/PHPStep 1 - Place the PHP binary If you have decided to configure FastCGI/PHP by using the Local Responder method and are using Zeus Web Server 4.2 or later, you can setup PHP very easily. If you aren't using Zeus Web Server 4.3 or above (which already include PHP configured as below), then perform the following steps:
To activate PHP for a virtual server, enable PHP in the Third Party configuration section of the Administration Server. No further configuration is required when using this method. Instructions later in this document describe how to test that your configuration is working correctly. If you are not using Zeus Web Server 4.2, or would like to run PHP as a Remote Responder (recommended for high-traffic sites), you will need to configure PHP manually, as follows:
Now that your Zeus Web Server FastCGI/PHP on the local machine configuration is complete, it is time to move on to tuning the PHP and then operating system. If you wish to use Remote Reponders on a separate machine. Perform the following steps:
Step 2 - Start PHP as a FastCGI runner Before we start the runner, it is neccessary to set to enviroment variables. Default values will be used for now but please see the Tuning section later in this document to determine the most appropriate values for your system.
Now start the FastCGI runner as follows:
Substitute the appropriate values for $ZEUSHOME and <path to php binary>; also substitute for 8002 the port you chose above. Note that the FastCGI service will now be listening on the specified port, and should be subject to standard security policies. Please note that in Zeus 3.3.8, the 'fcgirunner' program requires perl to be installed. Further, it searches for perl in /usr/local/bin/perl. If it is not found there, you will see a 'file not found' error message. To correct this, put a symlink in /usr/local/bin to the real location of perl:
To stop the fcgirunner you will need to manually kill the running PHP processes. (Use ps and kill). Since the web server is configured to use a 'remote' FastCGI runner, the web server itself will not be aware of what PHP processes are running. The following example script written for linux will stop the FastCGI runner:
Starting and stopping the FastCGI runner can be performed at the same time as the Zeus Web Server. You can do this using an executable SysV init script, placed in $ZEUSHOME/rc.d/S50external_php. Note: You should avoid editing $ZEUSHOME/stop-zeus and $ZEUSHOME/start-zeus as these files are overwritten during product upgrades. You can download an example script for Linux only. This script must be modified as indicated to use the paths appropriate for your installation. Whilst the "fcgirunner" script must be started by the root user, the FastCGI runner itself should execute as a non-root user - especially if you start the runner from your rc script. To do this, ensure that you specify an alternative non-privileged username and group that the fcgirunner script should through the use of the --user and --group flags. We advise against running FastCGI programs as root.
The process ID of the fastcgi process will be stored in $PIDFILE (eg. /var/run/fcgiphp.pid). Please chmod this file to 666 so the script has the correct read+write permissions. Now, you can cleanly shut the process down using:
Use 'fcgirunner --help' or view the manpages for more information. Step 3 - Test the installation Create a file $DOCROOT/info.php containing the single line:
From a browser, verify that fetching this file gives a valid page If the above file can be displayed without error then, congratulations, you now have a basic working FastCGI/PHP installation. It is now neccessary ensure that there are enough PHP processes to handle the incomming connections. Tuning FastCGI/PHP and the Operating SystemTuning FastCGI/PHP When you start PHP, it will pre-fork a given number of child processes to handle incoming PHP requests. Each process will handle a given number of requests before exiting (and being replaced by a newly forked process). You can control these two parameters by setting the following environment variables BEFORE starting the FastCGI runner:
If you are running PHP as a FastCGI, you can set these values in the FastCGI pages of the Admin Server under the section entitled 'Configuring Additional FastCGI Enviroment Variables'. Note: When using PHP 4.3.0 and above, the default setting for PHP_FCGI_CHILDREN is "0". If you fail to set this variable to a higher value than the default, the PHP binary will not fork resulting in only one PHP request being processed at a time. To choose suitable values for PHP_FCGI_CHILDREN and PHP_FCGI_MAX_REQUEST, we recommend you use a load testing program, e.g. ApacheBench, to exercise the web server whilst measuring the server system utilization (with e.g. top or vmstat). If, by increasing the load offered up by ApacheBench, you are not able to drive the server to 100% utilization, you will probably need to increase PHP_FCGI_CHILDREN. (An example would be, if a PHP script is blocked for a long time waiting for a response to a backend database, the server will be unable to handle more than PHP_FCGI_CHILDREN concurrent requests). Tuning the Operating System If you are running FastCGI/PHP as a Remote Responder and are expecting substantial PHP load when the site is deployed, it is likely that you will want to raise the number of ephemeral ports available on your server due to the number of TCP TIME_WAIT states that will accrue. Please consult the relevant documentation for your OS e.g. under Linux you will need to:
You may also need to raise the number of file descriptors available, bothper-process and system-wide. Again, please consult the relevant documentation for your OS along with the Support FAQ on dealing with file descriptor shortages. Ensuring the suitability of the tuning values It is recommended that you load test you FastCGI/PHP responders on a test platform prior to releasing on a live site. This will highlight any Operating Sytem resource limitations issues. Benchmarking programs can be used to simulate load which will help you to determine the optimum tuning values. Zeus Technology have Performance engineers who are experienced in this field and can offer advice on getting the most out of your system. Please contact sales@zeus.com for more information. Building and Installing CGI/PHPIt is also possible to run PHP as a CGI. We would recommend this when you are allowing customers to run their own scripts on the system and you need to enforce access control or process limits on those scripts.
Authentication with PHPBy default, authentication information is not passed on to content generators such as PHP. If you wish your PHP scripts to check usernames and passwords using HTTP's Basic authentication, you must turn this on manually. To do this, ensure that htaccess is enabled on the virtual server. The appropriate .htaccess file(s) (such as the global htaccess file) should contain the directive 'passenvauthorization on'. Comments:This public messageboard is not a forum for technical support. To report technical support problems, please contact our dedicated Support team using the instructions at the bottom of this page.
Comment from:
test [Visitor]
Under FreeBSD7,when use
fcgirunner --addr=127.0.0.1 2008 /usr/local/bin/php-cgi then come out with fllowing error: bind( 127.0.0.1:2008 ): Can't assign requested addres
Comment from:
tester [Visitor]
The latest PHP 5.3 is not working.
Please suggest a solution to implement php 5.3. thanks |
Recently...
Other Resources
|





