CGI setup on Sun, iPlanet and Netscape servers

Copy php4ts.dll to your systemroot
(the directory where you installed Windows)

Make a file association from the command line.
Type the following two lines:

assoc .php=PHPScript
ftype PHPScript=c:\php\php.exe %1 %*

In the Netscape Enterprise Administration Server create
a dummy shellcgi directory and remove it just after (this
step creates 5 important lines in obj.conf and allow the
web server to handle shellcgi scripts).

(PHP >= 4.3.3) The php_ini parameter is
optional but with it you can place your
php.ini in your web server configuration directory.

Configure the default object in obj.conf
(for virtual server classes [Sun Web Server 6.0+] in
their vserver.obj.conf):
In the <Object name="default">
section, place this line necessarily after all 'ObjectType'
and before all 'AddLog' lines:

(PHP >= 4.3.3) As additional parameters you can add some special
php.ini-values, for example you
can set a docroot="/path/to/docroot"
specific to the context php4_execute
is called. For boolean ini-keys please use 0/1 as value,
not "On","Off",...
(this will not work correctly), e.g.
zlib.output_compression=1 instead of
zlib.output_compression="On"

This is only needed if you want to configure a directory that only consists of
PHP scripts (same like a cgi-bin directory):

After that you can configure a directory in the Administration server and assign it
the style x-httpd-php. All files in it will get executed as PHP.
This is nice to hide PHP usage by renaming files to .html.

The stacksize that PHP uses depends on the configuration of the web server. If you get
crashes with very large PHP scripts, it is recommended to raise it with the Admin Server
(in the section "MAGNUS EDITOR").

CGI environment and recommended modifications in php.ini

Important when writing PHP scripts is the fact that Sun JSWS/Sun ONE
WS/iPlanet/Netscape is a multithreaded web server. Because of that all
requests are running in the same process space (the space of the web server
itself) and this space has only one environment. If you want to get CGI
variables like PATH_INFO, HTTP_HOST
etc. it is not the correct way to try this in the old PHP way with
getenv() or a similar way (register globals to
environment, $_ENV). You would only get the environment
of the running web server without any valid CGI variables!

Informacja:

Why are there (invalid) CGI variables in the environment?

Answer: This is because you started the web server process from the admin server
which runs the startup script of the web server, you wanted to start, as a CGI script
(a CGI script inside of the admin server!). This is why the environment of
the started web server has some CGI environment variables in it. You can test
this by starting the web server not from the administration server. Use
the command line as root user and start it manually - you will see
there are no CGI-like environment variables.

Simply change your scripts to get CGI variables in the correct way for
PHP 4.x by using the superglobal $_SERVER. If you have
older scripts which use $HTTP_HOST, etc., you should turn
on register_globals in php.ini and change the variable
order too (important: remove "E" from it,
because you do not need the environment here):

variables_order = "GPCS"
register_globals = On

Special use for error pages or self-made directory listings (PHP >= 4.3.3)

You can use PHP to generate the error pages for "404 Not Found"
or similar. Add the following line to the object in obj.conf for
every error page you want to overwrite:

where XXX is the HTTP error code. Please delete
any other Error directives which could interfere with yours.
If you want to place a page for all errors that could exist, leave
the code parameter out. Your script can get the HTTP status code
with $_SERVER['ERROR_TYPE'].

Another possibility is to generate self-made directory listings.
Just create a PHP script which displays a directory listing and
replace the corresponding default Service line for
type="magnus-internal/directory"
in obj.conf with the following:

The NSAPI module now supports the nsapi_virtual() function
(alias: virtual())
to make subrequests on the web server and insert the result in the web page.
The problem is, that this function uses some undocumented features from
the NSAPI library.

Under Unix this is not a problem, because the module automatically looks
for the needed functions and uses them if available.
If not, nsapi_virtual() is disabled.

Under Windows limitations in the DLL handling need the use of a automatic
detection of the most recent ns-httpdXX.dll file.
This is tested for servers till version 6.1. If a newer version of the
Sun server is used, the detection fails and nsapi_virtual()
is disabled.

If this is the case, try the following:
Add the following parameter to php4_init in
magnus.conf/obj.conf:

Init fn=php4_init ... server_lib="ns-httpdXX.dll"

where XX is the correct DLL version number.
To get it, look in the server-root for the correct DLL name. The
DLL with the biggest filesize is the right one.