Using PHP on Sun Java System Web Server 7.0
Assuming that you have already installed web server, all you need to do is:
- Download the SJSWS 7.0 PHP Add-On 1.0 (Click to download).
- Unzip the contents on to a local drive, say C:\php. After
extracting the files, you should find the php executable (php-cgi.exe)
under C:\php\phppack-5_2_0-windows-i586\php (lets call it
<php_dir>
from now onwards).
- Use either CLI (Command Line Interface) or GUI (Graphical User
Interface) to configure PHP.
There are four different types of FASTCGI applications, namely: Authorizer, Responder, Filter and Error (Click here for more info). A 'fastcgi-handler' refers to the handle to one of these four roles.
1. Using GUI:
- From the Common Tasks page, click on 'Edit Virtual Server > Content Handling > FASTCGI'.
- Click New to create a new URI with FASTCGI handler mapping.
- By default, this mapping applies to the entire virtual server(lets say 'test' in this case). If you choose this option, web server looks for the files (to be served) in the default document root, which is <install_dir>/https-test/docs (<doc_root> from here onwards).
- Lets create a new URI called '/php/*' so that requests from http://localhost:1894/php/*.php will be served from '<doc_root>/php/'.
- Role is 'Responder' by default. From the drop down menu, choose
the role as per your requirement. Lets select 'Responder' for now,
which is used widely.
- Mime type is optional. Lets leave it for now.
- Out of Bind Path and Application Path, one of them must be provided. Providing both of them is also fine.
- Bind Path is a Unix Domain Socket or a Named Pipe or of the form host:port. Lets leave it for now.
- Application Path is the FASTCGI Server application path that processes the request. Applicatioin Path is most widely used compared to Bind Path. In our example, it is the path to the php executable: <php_dir>/php-cgi.exe.
- The next two attributes: Arguments and Environment Variables are applicable only when Applicatioin Path is specified and are also optional. Lets leave them for now.
- Click on OK to save changes. A FASTCGI enabled URI will be created successfully, but thats not all of it, you need to deploy the changes. Click on Deployment Pending link, followed by a click on Deploy button to deploy the configuration to all nodes. If you are creating a handler for the first time, you will be prompted to restart the instances. Choose 'Now' and click OK to restart the instance(s).
- Lets test whether php works fine or not.
- Make sure that you create directory named 'php' under <doc_root>. Create a test.php file with the contents as <? phpinfo() ?>, save and exit.
- Send a request (http://localhost:1894/php/test.php) to the web server from your browser. If PHP is configured properly, you should observe the following on your browser window (Note: only part of the image is copied here).
- There are 5 commands associated with a fastcgi-handler, namely create-fastcgi-handler, delete-fastcgi-handler, get-fastcgi-handler-prop, set-fastcgi-handler-prop, and list-fastcgi-handlers. The names are descriptive enough not to cause any confusion.
- Assuming that you are already connected to wadm, invoke
create-fastcgi-handler command on the cli prompt to get the usage.
-
wadm>create-fastcgi-handler
usage: create-fastcgi-handler [--echo] [--no-prompt] [--verbose] [--mime-type=type] [--uri-pattern=pattern] [--role=authorizer|responder|filter|error] [--app-path=path] [--app-args=arg1,arg2...] [--bind-path=path] [--min-procs=count] [--max
-procs=count] [--chroot=directory] [--server-user=user-id] [--group=group-id] [--nice=value] [--listen-queue-size=size] [--app-env='name=value','name=value'...] [--reuse-connection] [--connection-timeout=time-in-seconds] [--response-timeout
=time-in-seconds] [--restart-interval=minutes] [--request-retry=retry-count] [--error-url=url] [--error-reason=string] --config=name --vs=name
CLI014 config is a required option.
- Lets create a fastcgi handler with the role as 'Filter', by invoking the command as follows (Note: You need to escape '\' on Windows platform):
-
wadm> create-fastcgi-handler --config=test --vs=test --uri-pattern=/php/* --role=filter --app-path=C:\\php\\phppack-5_2_0-windows-i586\\php\\php-cgi.exe
CLI201 Command 'create-fastcgi-handler' ran successfully
- Deploy the config by invoking the following command.
-
wadm> deploy-config test
CLI201 Command 'deploy-config' ran successfully
- If you are creating the handler for the first time, you need to restart the instance as follows
-
wadm> restart-instance --config=test localhost
CLI202 Successfully restarted the server instance.
- Lets test a simple filter application to make sure that PHP works fine. Copy the files: <install_dir>/samples/fastcgi/pageCounter.php and <install_dir>/samples/fastcgi/counter.txt to <doc_root>/php. Send a request (http://localhost:1894/php/pageCounter.php) to the web server from your browser. If there are no issues during the configuration of PHP, you should observe the following (Note: the count increases as per the number of requests).
- Page Counter: 1
uu
Posted by 122.164.135.208 on February 26, 2008 at 04:03 PM IST #
Very useful! Thanks!
Posted by bp on April 22, 2008 at 06:43 PM IST #