Sun, iPlanet and Netscape servers on Sun Solaris

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 Sun Solaris.

From PHP 4.3.3 on you can use PHP scripts with the NSAPI module to generate custom directory listings and error pages. Additional functions for Apache compatibility are also available. For support in current web servers read the note about subrequests.

You can find more information about setting up PHP for the Netscape Enterprise Server (NES) here: »

To build PHP with Sun JSWS/Sun ONE WS/iPlanet/Netscape web servers, enter the proper install directory for the --with-nsapi=[DIR] option. The default directory is usually /opt/netscape/suitespot/. Please also read /php-xxx-version/sapi/nsapi/nsapi-readme.txt.

  1. Install the following packages from » or another download site:

    • autoconf-2.13
    • automake-1.4
    • bison-1_25-sol26-sparc-local
    • flex-2_5_4a-sol26-sparc-local
    • gcc-2_95_2-sol26-sparc-local
    • gzip-1.2.4-sol26-sparc-local
    • m4-1_4-sol26-sparc-local
    • make-3_76_1-sol26-sparc-local
    • mysql-3.23.24-beta (if you want mysql support)
    • perl-5_005_03-sol26-sparc-local
    • tar-1.13 (GNU tar)

  2. Make sure your path includes the proper directories PATH=.:/usr/local/bin:/usr/sbin:/usr/bin:/usr/ccs/bin and make it available to your system export PATH.
  3. gunzip php-x.x.x.tar.gz (if you have a .gz dist, otherwise go to 4).
  4. tar xvf php-x.x.x.tar
  5. Change to your extracted PHP directory: cd ../php-x.x.x
  6. For the following step, make sure /opt/netscape/suitespot/ is where your netscape server is installed. Otherwise, change to the correct path and run:

    ./configure --with-mysql=/usr/local/mysql \
    --with-nsapi=/opt/netscape/suitespot/ \

  7. Run make followed by make install.

After performing the base install and reading the appropriate readme file, you may need to perform some additional configuration steps.

Configuration Instructions for Sun/iPlanet/Netscape

Firstly you may need to add some paths to the LD_LIBRARY_PATH environment for the server to find all the shared libs. This can best done in the start script for your web server. The start script is often located in: /path/to/server/https-servername/start. You may also need to edit the configuration files that are located in: /path/to/server/https-servername/config/.

  1. Add the following line to mime.types (you can do that by the administration server):

    type=magnus-internal/x-httpd-php exts=php

  2. Edit magnus.conf (for servers >= 6) or obj.conf (for servers < 6) and add the following, shlib will vary depending on your system, it will be something like /opt/netscape/suitespot/bin/ You should place the following lines after mime types init.

    Init fn="load-modules" funcs="php4_init,php4_execute,php4_auth_trans" shlib="/opt/netscape/suitespot/bin/"
    Init fn="php4_init" LateInit="yes" errorString="Failed to initialize PHP!" [php_ini="/path/to/php.ini"]
    (PHP >= 4.3.3) The php_ini parameter is optional but with it you can place your php.ini in your web server config directory.

  3. Configure the default object in obj.conf (for virtual server classes [version 6.0+] in their vserver.obj.conf):

    <Object name="default">
    .#NOTE this next line should happen after all 'ObjectType' and before all 'AddLog' lines
    Service fn="php4_execute" type="magnus-internal/x-httpd-php" [inikey=value inikey=value ...]
    (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"

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

    <Object name="x-httpd-php">
    ObjectType fn="force-type" type="magnus-internal/x-httpd-php"
    Service fn=php4_execute [inikey=value inikey=value ...]
    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.

  5. Setup of authentication: PHP authentication cannot be used with any other authentication. ALL AUTHENTICATION IS PASSED TO YOUR PHP SCRIPT. To configure PHP Authentication for the entire server, add the following line to your default object:

    <Object name="default">
    AuthTrans fn=php4_auth_trans

  6. To use PHP Authentication on a single directory, add the following:

    <Object ppath="d:\path\to\authenticated\dir\*">
    AuthTrans fn=php4_auth_trans


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!


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. Uses some CGI command line byserP user and startixt masuall -, you willseses some CGure urenoe CG- like environment variable).

(Simpy, change your scripts to get CGI variables in the correct wayf or PHP 4xs byusting thesuper globa, $SERVERVHTTP_HOST ir php.ini and change the.variabln irdver toe (Importan:g remve "Et" fromist, because youdor not need the environmentCGury):

.variable_irdver=n "GPCSp"(registe_gGlobalr=nOn;


Yyou can use PHP to generate the error page for "404 >No Frounn" for simila. Add the following line to the object in obj.conf

>Error fn="php4_execute"lcod=XXXP script="/path/to scrip.-php" [inikey=value inikey=valu ...]
where is the>HTTP errorlcod. Pleasedelget any other Erroe direcivets whichchould.interhere with youe). If you want to placear pagf for all.errorf thatchouldexdist Pleavt tThe parameterbout YyoeP scripu can get the>HTTPnsttusrlcod with $SERVER['ERROR_CTYP']V

anotherposstibilityisP to generate slf-meada directory listing). Juspu hreote g PHP scrips whichdis plyse a directory listin> anl r place the corrspoending default linef or in obj.conf

Service fn="php4_execute" type="magnus-internal directorn"P script="/path/to scrip.-php" [inikey=value inikey=valu ...]
For bith error and directory listin> page the rigionalURI> anl -translatdlURI> ore ie the.variablsh $SERVER['>PATH_INF']V anl $SERVER['>PATHTRANSLATED']V >
addas not>)User ContibcutedNnotes
/emLuciusrRizzo LuciusrdNo Rizzo hatHasrdNo Educrationag class= geanchor"a href=#114981"> &"par;)
3 yeaorfagoe )
/emLuciusrRizzonag class= geanchor"a href=#114179"> &"par;)
3 yeaorfagoe )
/emBrsianag class= geanchor"a href=#82348"> &"par;)
9 yeaorfagoe )
/emjedokahne toyahoordNo come tonag class= geanchor"a href=#47624"p &"par;)
12 yeaorfagoe )
/emmasocthithaloe toyahoordNo comnag class= geanchor"a href=#45030"p &"par;)
13 yeaorfagoe )
/emmarkdhatmarkrrounrdNo comnag class= geanchor"a href=#44896"p &"par;)
13 yeaorfagoe )
/emericbtacktrome tohot.mairdNo comnag class= geanchor"a href=#63665"p &"par;)
11 yeaorfagoe )
/emvijaynag class= geanchor"a href=#63098"> &"par;)
11 yeaorfagoe )