<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Sun, iPlanet and Netscape servers on Microsoft Windows</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="install.windows.apache2.html">Apache 2.x on Microsoft Windows</a></div> <div class="next" style="text-align: right; float: right;"><a href="install.windows.sambar.html">Sambar Server on Microsoft Windows</a></div> <div class="up"><a href="install.windows.html">Installation on Windows systems</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="install.windows.sun" class="sect1"> <h2 class="title">Sun, iPlanet and Netscape servers on Microsoft Windows</h2> <p class="para"> This section contains notes and hints specific to Sun Java System Web Server, Sun ONE Web Server, iPlanet and Netscape server installs of PHP on Windows. </p> <p class="para"> From PHP 4.3.3 on you can use PHP scripts with the <a href="ref.nsapi.html" class="link">NSAPI module</a> to <a href="install.windows.sun.html#install.windows.sun.specialpages" class="link">generate custom directory listings and error pages</a>. Additional functions for Apache compatibility are also available. For support in current web servers read the <a href="install.windows.sun.html#install.windows.sun.notes" class="link">note about subrequests</a>. </p> <div class="sect2" id="install.windows.sun.cgi"> <h3 class="title">CGI setup on Sun, iPlanet and Netscape servers</h3> <p class="para"> To install PHP as a CGI handler, do the following: </p> <ul class="itemizedlist"> <li class="listitem"> <span class="simpara"> Copy <var class="filename">php4ts.dll</var> to your systemroot (the directory where you installed Windows) </span> </li> <li class="listitem"> <p class="para"> Make a file association from the command line. Type the following two lines: <div class="example-contents"> <div class="shellcode"><pre class="shellcode">assoc .php=PHPScript ftype PHPScript=c:\php\php.exe %1 %*</pre> </div> </div> </p> </li> <li class="listitem"> <span class="simpara"> 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). </span> </li> <li class="listitem"> <span class="simpara"> In the Netscape Enterprise Administration Server create a new mime type (Category: type, Content-Type: magnus-internal/shellcgi, File Suffix:php). </span> </li> <li class="listitem"> <span class="simpara"> Do it for each web server instance you want PHP to run </span> </li> </ul> <p class="para"> More details about setting up PHP as a CGI executable can be found here: <a href="http://benoit.noss.free.fr/php/install-php.html" class="link external">» http://benoit.noss.free.fr/php/install-php.html</a> </p> </div> <div class="sect2" id="install.windows.sun.nsapi"> <h3 class="title">NSAPI setup on Sun, iPlanet and Netscape servers</h3> <p class="para"> To install PHP with NSAPI, do the following: </p> <ul class="itemizedlist"> <li class="listitem"> <span class="simpara"> Copy <var class="filename">php4ts.dll</var> to your systemroot (the directory where you installed Windows) </span> </li> <li class="listitem"> <p class="para"> Make a file association from the command line. Type the following two lines: <div class="example-contents"> <div class="shellcode"><pre class="shellcode">assoc .php=PHPScript ftype PHPScript=c:\php\php.exe %1 %*</pre> </div> </div> </p> </li> <li class="listitem"> <span class="simpara"> In the Netscape Enterprise Administration Server create a new mime type (Category: type, Content-Type: magnus-internal/x-httpd-php, File Suffix: php). </span> </li> <li class="listitem"> <p class="para"> Edit <var class="filename">magnus.conf</var> (for servers >= 6) or <var class="filename">obj.conf</var> (for servers < 6) and add the following: You should place the lines after <em>mime types init</em>. <div class="example-contents"> <div class="cdata"><pre> Init fn="load-modules" funcs="php4_init,php4_execute,php4_auth_trans" shlib="c:/php/sapi/php4nsapi.dll" Init fn="php4_init" LateInit="yes" errorString="Failed to initialise PHP!" [php_ini="c:/path/to/php.ini"] </pre></div> </div> (PHP >= 4.3.3) The <em>php_ini</em> parameter is optional but with it you can place your <var class="filename">php.ini</var> in your web server configuration directory. </p> </li> <li class="listitem"> <p class="para"> Configure the default object in <var class="filename">obj.conf</var> (for virtual server classes [Sun Web Server 6.0+] in their <var class="filename">vserver.obj.conf</var>): In the <em><Object name="default"></em> section, place this line necessarily after all 'ObjectType' and before all 'AddLog' lines: <div class="example-contents"> <div class="cdata"><pre> Service fn="php4_execute" type="magnus-internal/x-httpd-php" [inikey=value inikey=value ...] </pre></div> </div> (PHP >= 4.3.3) As additional parameters you can add some special <var class="filename">php.ini</var>-values, for example you can set a <em>docroot="/path/to/docroot"</em> specific to the context <em>php4_execute</em> is called. For boolean ini-keys please use 0/1 as value, not <em>"On","Off",...</em> (this will not work correctly), e.g. <em>zlib.output_compression=1</em> instead of <em>zlib.output_compression="On"</em> </p> </li> <li class="listitem"> <p class="para"> This is only needed if you want to configure a directory that only consists of PHP scripts (same like a cgi-bin directory): <div class="example-contents"> <div class="cdata"><pre> <Object name="x-httpd-php"> ObjectType fn="force-type" type="magnus-internal/x-httpd-php" Service fn=php4_execute [inikey=value inikey=value ...] </Object> </pre></div> </div> After that you can configure a directory in the Administration server and assign it the style <em>x-httpd-php</em>. All files in it will get executed as PHP. This is nice to hide PHP usage by renaming files to <var class="filename">.html</var>. </p> </li> <li class="listitem"> <span class="simpara"> Restart your web service and apply changes </span> </li> <li class="listitem"> <span class="simpara"> Do it for each web server instance you want PHP to run </span> </li> </ul> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> More details about setting up PHP as an NSAPI filter can be found here: <a href="http://benoit.noss.free.fr/php/install-php4.html" class="link external">» http://benoit.noss.free.fr/php/install-php4.html</a> </p> </p></blockquote> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> 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"). </p> </p></blockquote> </div> <div class="sect2" id="install.windows.sun.phpini"> <h3 class="title">CGI environment and recommended modifications in <var class="filename">php.ini</var></h3> <p class="para"> 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 <em>PATH_INFO</em>, <em>HTTP_HOST</em> etc. it is not the correct way to try this in the old PHP way with <span class="function"><a href="function.getenv.html" class="function">getenv()</a></span> or a similar way (register globals to environment, <em>$_ENV</em>). You would only get the environment of the running web server without any valid CGI variables! </p> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> Why are there (invalid) CGI variables in the environment? </p> <p class="para"> 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. </p> </p></blockquote> <p class="para"> Simply change your scripts to get CGI variables in the correct way for PHP 4.x by using the superglobal <var class="varname"><var class="varname"><a href="reserved.variables.server.html" class="classname">$_SERVER</a></var></var>. If you have older scripts which use <var class="varname"><var class="varname">$HTTP_HOST</var></var>, etc., you should turn on <em>register_globals</em> in <var class="filename">php.ini</var> and change the variable order too (important: remove <em>"E"</em> from it, because you do not need the environment here): <div class="example-contents"> <div class="cdata"><pre> variables_order = "GPCS" register_globals = On </pre></div> </div> </p> </div> <div class="sect2" id="install.windows.sun.specialpages"> <h3 class="title">Special use for error pages or self-made directory listings (PHP >= 4.3.3)</h3> <p class="para"> You can use PHP to generate the error pages for <em>"404 Not Found"</em> or similar. Add the following line to the object in <var class="filename">obj.conf</var> for every error page you want to overwrite: <div class="example-contents"> <div class="cdata"><pre> Error fn="php4_execute" code=XXX script="/path/to/script.php" [inikey=value inikey=value...] </pre></div> </div> where <em>XXX</em> is the HTTP error code. Please delete any other <em>Error</em> directives which could interfere with yours. If you want to place a page for all errors that could exist, leave the <em>code</em> parameter out. Your script can get the HTTP status code with <var class="varname"><var class="varname"><a href="reserved.variables.server.html" class="classname">$_SERVER['ERROR_TYPE']</a></var></var>. </p> <p class="para"> 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 <em>type="magnus-internal/directory"</em> in <var class="filename">obj.conf</var> with the following: <div class="example-contents"> <div class="cdata"><pre> Service fn="php4_execute" type="magnus-internal/directory" script="/path/to/script.php" [inikey=value inikey=value...] </pre></div> </div> For both error and directory listing pages the original URI and translated URI are in the variables <var class="varname"><var class="varname"><a href="reserved.variables.server.html" class="classname">$_SERVER['PATH_INFO']</a></var></var> and <var class="varname"><var class="varname"><a href="reserved.variables.server.html" class="classname">$_SERVER['PATH_TRANSLATED']</a></var></var>. </p> </div> <div class="sect2" id="install.windows.sun.notes"> <h3 class="title">Note about <span class="function"><a href="function.nsapi-virtual.html" class="function">nsapi_virtual()</a></span> and subrequests (PHP >= 4.3.3)</h3> <p class="para"> The NSAPI module now supports the <span class="function"><a href="function.nsapi-virtual.html" class="function">nsapi_virtual()</a></span> function (alias: <span class="function"><a href="function.virtual.html" class="function">virtual()</a></span>) 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. </p> <p class="para"> Under Unix this is not a problem, because the module automatically looks for the needed functions and uses them if available. If not, <span class="function"><a href="function.nsapi-virtual.html" class="function">nsapi_virtual()</a></span> is disabled. </p> <p class="para"> Under Windows limitations in the DLL handling need the use of a automatic detection of the most recent <var class="filename">ns-httpdXX.dll</var> file. This is tested for servers till version 6.1. If a newer version of the Sun server is used, the detection fails and <span class="function"><a href="function.nsapi-virtual.html" class="function">nsapi_virtual()</a></span> is disabled. </p> <p class="para"> If this is the case, try the following: Add the following parameter to <em>php4_init</em> in <var class="filename">magnus.conf</var>/<var class="filename">obj.conf</var>: <div class="example-contents"> <div class="cdata"><pre> Init fn=php4_init ... server_lib="ns-httpdXX.dll" </pre></div> </div> where <em>XX</em> 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. </p> <p class="para"> You can check the status by using the <span class="function"><a href="function.phpinfo.html" class="function">phpinfo()</a></span> function. </p> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> But be warned: Support for <span class="function"><a href="function.nsapi-virtual.html" class="function">nsapi_virtual()</a></span> is EXPERIMENTAL!!! </p> </p></blockquote> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="install.windows.apache2.html">Apache 2.x on Microsoft Windows</a></div> <div class="next" style="text-align: right; float: right;"><a href="install.windows.sambar.html">Sambar Server on Microsoft Windows</a></div> <div class="up"><a href="install.windows.html">Installation on Windows systems</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>