©
This document uses PHP Chinese website manual Release
本节包含了在 Sun Solaris 平台的 Sun Java System web Server、Sun ONE web Server、iPlanet 和 Netscape 下安装 PHP 的说明和提示。
从 PHP 4.3.3 起,可以使用基于 NSAPI模块 PHP 脚本来生成自定义目录列表和错误页面。更多与 Apache 兼容的功能也可以使用。要了解如何在当前的 web 服务器中支持此功能,请阅读关于子请求(subrequests)的注释。
可以在下面的链接中了解更多关于在 Netscape Enterprise Server(NES)中设置 PHP 的信息:» http://benoit.noss.free.fr/php/install-php4.html。
要在 Sun JSWS/Sun ONE WS/iPlanet/Netscape web 服务器中编译 PHP,请为 --with-nsapi=[DIR] 输入合适的安装目录。默认的目录通常是 /opt/netscape/suitespot/。还可以阅读 /php-xxx-version/sapi/nsapi/nsapi-readme.txt。
从 » http://www.sunfreeware.com/ 或其它下载站点安装下面的软件包:
export PATH
命令将其导出为环境变量。
gunzip php-x.x.x.tar.gz
(如果使用 .gz 版本,否则跳到 4)
tar xvf php-x.x.x.tar
cd ../php-x.x.x
在下面的步骤中,请确认 Netscape 服务器安装在 /opt/netscape/suitespot/ 目录中。否则,将下面命令中的该路径修改为正确的路径并运行:
./configure --with-mysql=/usr/local/mysql \ --with-nsapi=/opt/netscape/suitespot/ \ --enable-libgcc
在执行了基础的安装并阅读相应的 Readme 文件后,还需要执行一些额外的配置步骤。
首先需要为 LD_LIBRARY_PATH 环境变量添加一些路径,以便服务器找到所需的共享库。可以使用 web 服务器的启动脚本很好的完成这一工作。启动脚本通常位于:/path/to/server/https-servername/start。或许需要编辑其配置文件,它位于:/path/to/server/https-servername/config/。
添加下面一行到 mime.types(可以在管理服务器中添加):
type=magnus-internal/x-httpd-php exts=php
编辑 magnus.conf(若服务器 >= 6)或 obj.conf(若服务器 < 6)并添加下述内容。shlib 的值根据系统的配置会有所不同。它可能类似于 /opt/netscape/suitespot/bin/libphp4.so。应该在 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"]
在 obj.conf 中配置默认对象(对于虚拟服务器的类 [版本 6.0+] 是在 vserver.obj.conf中):
<Object name="default"> . . . .#注意 下面一行添加在所有“ObjectType”之后,所有“AddLog”之前 Service fn="php4_execute" type="magnus-internal/x-httpd-php" [inikey=value inikey=value ...] . . </Object>
本步骤仅在需要配置一个由 PHP 脚本组成的目录时由必要执行(类似于一个 cgi-bin目录):
<Object name="x-httpd-php"> ObjectType fn="force-type" type="magnus-internal/x-httpd-php" Service fn=php4_execute [inikey=value inikey=value ...] </Object>
认证的设置:PHP 认证不能与其它任何类型的认证一起工作。所有认证被传递到 PHP 脚本。要为整个服务器配置 PHP 认证,在默认对象中添加下面一行:
<Object name="default"> AuthTrans fn=php4_auth_trans . . . </Object>
要在单一目录使用 PHP 认证,添加如下内容:
<Object ppath="d:\path\to\authenticated\dir\*"> AuthTrans fn=php4_auth_trans </Object>
Note:
PHP 使用的堆栈大小取决于 web 服务器的配置。如果运行很大的 PHP 脚本时程序崩溃,推荐在 Admin Server(在“MAGNUS EDITOR”一节)中增大此项。
当编写 PHP 脚本时,应特别注意 Sun JSWS/Sun ONE WS/iPlanet/Netscape 是一个多线程 web 服务器。因此,所有请求都运行在相同的进程空间(Web 服务器自己的空间),该空间仅有一套环境变量。如果想获得 CGI 变量,例如 PATH_INFO、HTTP_HOST 等,使用原有的 PHP 3.x 的方式( getenv() ),或使用类似的方式(注册全局变量到环境变量, $_ENV ),都是不可行的。只能获得运行中的 web 服务器的环境变量,而不能获得任何有效的 CGI 变量!
Note:
为什么在环境中存在(无效的)CGI 变量?
答:这是因为从管理服务器中启动 web 服务器进程时,运行了 web 服务器的启动脚本,它事实上是一个 CGI 脚本(管理服务器中的一个 CGI 脚本!)。这便是为什么启动的 web 服务器包含一些 CGI 变量。可以尝试不从管理服务器启动 web 服务器,用 root 用户登录使用命令行手动启动它,会发现这些 CGI 形式的变量不复存在。
要在 PHP 4.x 中正确获得 CGI 变量,仅需修改脚本使用超级全局变量 $_SERVER 。如果老脚本中使用了 $HTTP_HOST 等变量,应该在 php.ini 中打开 register_globals,并且要修改变量顺序(注意:从中删除 "E",因为不需要这里的环境变量):
variables_order = "GPCS" register_globals = On
可以使用 PHP 为 "404 Not Found" 或类似的错误代码生成错误页面。将下面几行添加到 obj.conf 中以覆盖默认的错误页面:
Error fn="php4_execute" code=XXX script="/path/to/script.php" [inikey=value inikey=value...]
另一种可能是生成自造目录列表。只要创建一个 PHP 脚本,来显示目录列表 并在 obj.conf 中为 type="magnus-internal/directory" 将相应的默认 Service 行替换为:
Service fn="php4_execute" type="magnus-internal/directory" script="/path/to/script.php" [inikey=value inikey=value...]
NSAPI 模块现在支持 nsapi_virtual() 函数(别名: virtual() ),用来在 web 服务器上创建子请求(subrequests)和在 web 页面插入请求的结果。此函数使用了一些 NSAPI 中还没有文档说明的函数。在 Unix 下,该模块自动查找需要的函数,若它们存在则使用它们。若不存在,函数 nsapi_virtual() 被禁用。
Note:
但是要注意,对 nsapi_virtual() 的支持是试验性质的!
[#1] Lucius Rizzo Lucius dot Rizzo at Has dot Education [2014-05-09 06:24:12]
In case we.je (the originating domain) is dropped, I thought I'd add one that should last longer
The new URL is:
http://our.guru/oracle-iplanet-web-server-running-on-arch-linux-with-php-fpm-hello-speed-meet-kettle/
--
Lucius Rizzo
www.Lucius.Tel
[#2] Lucius Rizzo [2014-01-21 17:38:38]
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 Rizzo
www.say.si
[#3] Brian [2008-04-07 07:15:47]
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
[#4] yairl at savion dot huji dot ac dot il [2007-11-29 05:01:44]
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
[#5] ericbackstrom at hotmail dot com [2006-03-27 15:09:50]
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"
[#6] vijay [2006-03-13 06:48:45]
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
[#7] jedokahn at yahoo dot com at [2004-11-23 00:50:10]
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.
[#8] masochisthalo at yahoo dot com [2004-08-23 14:28:43]
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
[#9] mark at markround dot com [2004-08-19 09:36:39]
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]