Sun Java System Web Server 7.0 Update 2 Administrator's Guide

Modify the obj.conf

Edit obj.conf file to configure FastCGI specific requests using the plug-in SAFs described in the earlier sections.

An example of modified obj.conf file is shown below:

#

# Copyright 2006 Sun Microsystems, Inc. All rights reserved.

# Use is subject to license terms.

#


# You can edit this file, but comments and formatting changes

# might be lost when you use the administration GUI or CLI.



<object name = "default">

		AuthTrans fn="match-browser" browser="*MSIE*" 
						ssl-unclean-shutdown="true"
		NameTrans fn="ntrans-Java EE" name="Java EE"
		NameTrans fn="pfx2dir" from="/mc-icons" 
						dir="/ws7/lib/icons" name="es-internal"
		NameTrans fn="assign-name" from="/fcgi/*" name="fcgi.config"

</object>

<Object name="fcgi.config">

		AuthTrans fn="auth-fastcgi" app-path="/fastcgi/apps/c/simpleAuth" 
				bind-path="localhost:2111"
		Service fn="responder-fastcgi" 
						app-path="/fastcgi_enabled_php_installation_dir/bin/php" 
				app-env="name1=abc"

</object>
...

Note that FastCGI SAFs can be invoked in different ways by defining different objects for different URL patterns or mapping the SAFs to different MIME types.

For more information on obj.conf configuration and syntax, refer to the Administration Configuration File Reference Guide.

Configuring Multiple FastCGI Applications

You cannot configure multiple FastCGI applications through Administration Console or CLI. As a workaround, you can configure multiple applications by modifying the obj.conf file. For example

<If> $uri =~ '^/fcgi/(.*)'>

Service fn="responder-fastcgi" app-path="/home/bits/fastcgi/fcgi-2.4.0/examples/$1" 
app-env="LD_LIBRARY_LIBRARY_
PATH=/home/bits/fastcgi/fcgi-2.4.0/libfcgi/.libs"</If>

The expression creates <app-path> process, which does not need to be configured separately.


Note –

You cannot configure the same bind-path for multiple applications. This would result in failure of startup, due to common

bind-path.


Configuring PHP with FastCGI in a Hosting Environment

To configure FastCGI in virtual hosting environment, ensure that Sun specific PHP plug-in bundled with the setup is installed in the <install-dir/plugins directory. In the following example, the a mime type for PHP requests is defined and a FastCGI handler is created that accepts all PHP requests.

bash-2.05#./wadm --user=admin --password-file=pwdfile
Connected to localhost:38989
Sun Java System Web Server 7.0U2 B12/09/2007 09:02

wadm> create-mime-type  --config=php --extensions=php,php3,php4,php5 magnus-internal/php
CLI201 Command 'create-mime-type' ran successfully

wadm> create-fastcgi-handler --app-path=/ws70u2/plugins/php/bin/php 
--bind-path="\$(lc(\$urlhost))" 
--mime-type=magnus-internal/php 
--app-env=PHPRC=/$(lc(\$urlhost)),PHP_FCGI_CHILDREN=5,PHP_FCGI_MAX_REQUEST=200,LD_LIBRARY_PATH=/ws70u2/plugins/php 
--min-procs=1 --restart-interval=10 --request-retry=5 --config=php --vs=php

CLI201 Command 'create-fastcgi-handler' ran successfully

wadm> deploy-config php
CLI201 Command 'deploy-config' ran successfully

You can use the same PHP binary for all URL hosts configured in an instance. The configuration ensures that each PHP process has its own UNIX Domain Socket (UDS) same name as the URL host. The request from different hosts invokes the unique php.ini file from the app-path.


Note –

The php.in file is not mandatory to run PHP, it can be used to modify the default settings.


For more information, see the CLI reference create-fastcgi-handler(1)

Sample Configuration File

This is a sample configuration file that configures PHP with FastCGI.

<If -f $path>
Service type="magnus-internal/php"
    fn="responder-fastcgi"
    app-path="/opt/coolstack/php5/bin/php-cgi"
    bind-path="localhost:3101"
    app-env="PHPRC=/opt/coolstack/php5"
    app-env="PHP_FCGI_CHILDREN=5"
    app-env="PHP_FCGI_MAX_REQUEST=200"
    app-env="FCGI_WEB_SERVER_ADDRS=127.0.0.1"
    req-retry=5
    restart-interval=10
    bucket="php-bucket"

</If>
<Else>
Service type="magnus-internal/php" fn="set-variable" error="404"
</Else>