DevConf 2015

## 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: » http://benoit.noss.free.fr/php/install-php4.html

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 »  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 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/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 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 ...]
.
.
</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>


Nota:

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").

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! Nota: 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: 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 web server and insert the result in the web page. 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.

Nota:

But be warned: Support for nsapi_virtual() is EXPERIMENTAL!!!

### User Contributed Notes 9 notes

Lucius Rizzo Lucius dot Rizzo at Has dot Education
1 year ago
 In case we.je (the originating domain) is dropped, I thought I'd add one that should last longerThe new URL is: http://our.guru/oracle-iplanet-web-server-running-on-arch-linux-with-php-fpm-hello-speed-meet-kettle/--Lucius Rizzowww.Lucius.Tel 
Lucius Rizzo
1 year ago
 http://we.je/oracle-iplanet-web-server-running-on-arch-linux-with-php-fpm-hello-speed-meet-kettle/If you are looking to setup Oracle iPlanet Web server using the much more effective option of using php-fpm, please follow the link above to learn how to accomplish this. Lucius Rizzowww.say.si 
Brian
7 years ago
 For me at least, this part of the second line in the magnus.conf is not optional:Init fn="php5_init" LateInit="yes"Without it, the web server crashes when trying to execute php files 
yairl at savion dot huji dot ac dot il
7 years ago
 For installation instruction for the new Sun One 7 webserver you must read the following doc. PHP 5.2.X will work fine, old version needs some changes.http://developers.sun.com/webtier/reference/techart/php2.html 
ericbackstrom at hotmail dot com
9 years ago
 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 :SWhen 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
9 years ago
 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?ThanksVijay 
jedokahn at yahoo dot com at
10 years ago
 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
10 years ago
 Title: Barebones PHP Installation on Sun One Web Server 6.1 for JDS2Author: Hijinio Reynoso Jr.Last Updated: August 23, 2004Summary: 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 Installer1. 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:> make4. 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]/config6. vi mime.types (or other editor) to add this line into it:type=magnus-internal/x-httpd-php exts=php7. 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
10 years ago
 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]