PHP: Sun, iPlanet and Netscape servers on Sun Solaris - Manual

downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

CGI and commandline setups fhttpd related notes

Last updated: Fri, 26 Jan 2007

view this page in

# 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 webservers read the note about subrequests.

You can find more information about setting up PHP for the Netscape Enterprise Server (NES) here: http://benoit.noss.free.fr/php/install-php4.html

To build PHP with Sun JSWS/Sun ONE WS/iPlanet/Netscape webservers, 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 http://www.sunfreeware.com/ 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/ \
       --enable-libgcc

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 webserver. 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/libphp4.so`. 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/libphp4.so"
       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 webserver 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 ...]
       .
       .
       </Object>

   (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 ...]
       </Object>

   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
       .
       .
       .
       </Object>

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

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

> Замечание: The stacksize that PHP uses depends on the configuration of the webserver. 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 webserver 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 3.x way with getenv() or a similar way (register globals to environment, `$_ENV`). You would only get the environment of the running webserver without any valid CGI variables!

> Замечание: Why are there (invalid) CGI variables in the environment?

> Answer: This is because you started the webserver process from the admin server which runs the startup script of the webserver, you wanted to start, as a CGI script (a CGI script inside of the admin server!). This is why the environment of the started webserver has some CGI environment variables in it. You can test this by starting the webserver 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:

    Error fn="php4_execute" code=XXX script="/path/to/script.php" [inikey=value inikey=value...]

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:

    Service fn="php4_execute" type="magnus-internal/directory" script="/path/to/script.php" [inikey=value inikey=value...]

For both error and directory listing pages the original URI and translated URI are in the variables `$_SERVER['PATH_INFO']` and `$_SERVER['PATH_TRANSLATED']`.

## Note about nsapi_virtual() and subrequests (PHP >= 4.3.3)

The NSAPI module now supports the nsapi_virtual() function (alias: virtual()) to make subrequests on the webserver and insert the result in the webpage. This function uses some undocumented features from the NSAPI library. On Unix the module automatically looks for the needed functions and uses them if available. If not, nsapi_virtual() is disabled.

> Замечание: But be warned: Support for nsapi_virtual() is EXPERIMENTAL!!!

add a note User Contributed Notes
Sun, iPlanet and Netscape servers on Sun Solaris
ericbackstrom at hotmail dot com
27-Mar-2006 03:09
`Using gcc 3.3 I had problems compiling PHP for 64 bits, I had to replace mysql/64 bits with mysql/32 bits (Solaris cannot mix 32 bits and 64 bits libraries), so I specified the following compiler flag:
CFLAGS="-m32";export CFLAGS;
I also had problems with PHP 5.1.2 in sapi/nsapi/nsapi.c source code, It had incorrect comments and file paths :S
When trying to install PHP with mysql support I found I had these problems too: http://bugs.php.net/bug.php?id=34516... So don't mix sun ld and gcc ld because you will get into troubles. I built mysql libraries myself in a separated directory.
And don't forget to set your LD_LIBRARY_PATH to something like:
LD_LIBRARY_PATH="/usr/local/lib:/usr/lib"`
vijay
13-Mar-2006 06:48
`If I start my iPlanet (v6.0 SP2) webserver with PHP5.1.2 i get this message every 1/2 sec in my error log....
[12/Mar/2006:11:01:48] failure (15936): Failed to read kernel statistics structures (No such device or address)
This happens only if I start my server loading PHP module. FYI - When I configured my php I had it use oracle instant client libraries.
One fix I found was to comment out this line in my magnus.conf file.
#Init fn="stats-init" profiling="on"
But I don't think i can do this on my prodcution machine. Any ideas to come around this issue?
Thanks
Vijay`
jedokahn at yahoo dot com at
23-Nov-2004 12:50
`I noted and installed *all* pkgs required to compile PHP5 but kept getting an error on compile when it attempted to test the gcc compiler. The /usr/ccs/bin and all the $PATH requirements were ALL there....why the error? I tried running gcc from the command prompt and got a "gcc: fatal: libiconv.so.2: open failed: "....DUH I needed to install the libiconv pkg from sunfreeware.com for gcc compiler to work. Just a small bonehead maneuver, but I thought I would add it just in case someone else ran into the particular problem.`
masochisthalo at yahoo dot com
23-Aug-2004 02:28
`Title: Barebones PHP Installation on Sun One Web Server 6.1 for JDS2
Author: Hijinio Reynoso Jr.
Last Updated: August 23, 2004
Summary: If you have installed Sun One Web Server 6.1 on the JDS (aka Java Desktop System from Sun), this will help you get PHP installed on it (without XML and MySQL support.) In any case, this should get you started which is better than not having it installed at all. These directions were based mainly on those available from PHP.net, but updated to meet the needs of this specific configuration.
Instructions
----------------------------
0. Make sure your web server isn't running and ensure that all JDS developer packages are installed; to be safe, I always ensure that all developer packages are available via Applications > System Tools > Administration > Software Installer
1. Download http://us3.php.net/get/php-5.0.1.tar.bz2/from/a/mirror and extract into the directory of your choice. (5.0.1 was the only version I could get to make install correctly)
2. CD into the extracted PHP directory and type:
> ./configure --with-nsapi=/opt/SUNWwbsvr --enable-libgcc --disable-libxml
(Your web server directory may vary from the above's default.)
3. Once it's done configuring (and it should be successful should you have all the proper packages), type:
> make
4. When its done compiling, it's time to install as root:
# make install
5. Now, configuration of your web server begins:
# cd /opt/SUNWwbsvr/https-[yourWebServer]/config
6. vi mime.types (or other editor) to add this line into it:
type=magnus-internal/x-httpd-php exts=php
7. vi magnus.conf to add the following 2 lines to end of it: (NOTE: the 2nd line could be optional)
Init fn="load-modules" funcs="php5_init,php5_execute,php5_auth_trans" shlib="/opt/SUNWwbsvr/bin/libphp5.so"
Init fn="php5_init" LateInit="yes" errorString="Failed to initialize PHP!" [php_ini="/path/to/php.ini"]
8. vi obj.conf to add the following line to <Object name="default">. Make sure this happens after all "ObjectType" entries and before any "AddLog" entries: (NOTE: for virtual servers, edit vserver.obj.conf)
Service fn="php5_execute" type="magnus-internal/x-httpd-php" [inikey=value inikey=value ...]
9. Now, start up your web server. Also, make sure to log into the admin server and click the "Apply" button in there. You will also have set "index.php" as an index filename in your virtual server's Document Preferences.
10. Congrats! Now, you have PHP installed! Of course, there are other features you could enable (MySQL, XML, etc.), but I haven't tested against those. Just consult the following page for hints: http://www.php.net/manual/en/install.unix.sun.php`
mark at markround dot com
19-Aug-2004 09:36
`Quick note : By replacing "php4" with "php5", the above instructions work perfectly when building PHP5 for an iPlanet server. EG:-
Init fn="load-modules" funcs="php5_init,php5_execute,php5_auth_trans" etc.
Works fine here on 6.0SP2, Solaris 9 Sparc.
-Mark
[mark at markround dot com]`
add a note
CGI and commandline setups fhttpd related notes

Last updated: Fri, 26 Jan 2007
show source | credits | stats | sitemap | contact | advertising | mirror sites
Copyright © 2001-2007 The PHP Group
All rights reserved.
This mirror generously provided by: Yahoo! Inc.
Last updated: Sat Mar 10 09:32:46 2007 PST