略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: Sun Solaris 上的 Sun、iPlanet 和 Netscape 服务器

2024-12-23

Sun Solaris 上的 Sun、iPlanet 和 Netscape 服务器

本节包含了在 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

  1. » http://www.sunfreeware.com/ 或其它下载站点安装下面的软件包:

    • 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(如果想要 mysql 支持)
    • perl-5_005_03-sol26-sparc-local
    • tar-1.13(GNU tar)
  2. 请确认 PATH 变量包含适当的目录 PATH=.:/usr/local/bin:/usr/sbin:/usr/bin:/usr/ccs/bin,并使用 export PATH命令将其导出为环境变量。
  3. gunzip php-x.x.x.tar.gz(如果使用 .gz 版本,否则跳到 4)
  4. tar xvf php-x.x.x.tar
  5. 进入 PHP 解压缩后的目录: cd ../php-x.x.x
  6. 在下面的步骤中,请确认 Netscape 服务器安装在 /opt/netscape/suitespot/ 目录中。否则,将下面命令中的该路径修改为正确的路径并运行:

    ./configure --with-mysql=/usr/local/mysql \
    --with-nsapi=/opt/netscape/suitespot/ \
    --enable-libgcc
  7. 运行 make,然后运行 make install

在执行了基础的安装并阅读相应的 Readme 文件后,还需要执行一些额外的配置步骤。

Sun/iPlanet/Netscape 的配置说明

首先需要为 LD_LIBRARY_PATH 环境变量添加一些路径,以便服务器找到所需的共享库。可以使用 web 服务器的启动脚本很好的完成这一工作。启动脚本通常位于:/path/to/server/https-servername/start。或许需要编辑其配置文件,它位于:/path/to/server/https-servername/config/

  1. 添加下面一行到 mime.types(可以在管理服务器中添加):

    type=magnus-internal/x-httpd-php exts=php
    
  2. 编辑 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"]
    
    (PHP >= 4.3.3)php_ini 参数是可选的。但是若使用它,便可以将 php.ini 放到 web 服务器的配置目录中去。
  3. 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 >= 4.3.3)作为附加的参数,可以在 php.ini 中添加一些特别的配置选项。例如可以设置 docroot="/path/to/docroot" 指向 php4_execute 被调用的上下文(context)。对于布尔 ini 键值,请使用 0/1 作为其值,而不是 "On"、"Off" 等(它们是无效的),例如,使用 zlib.output_compression=1,而不应使用 zlib.output_compression="On"
  4. 本步骤仅在需要配置一个由 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>
    
    之后,可以在管理服务器中配置一个目录,分配给它 x-httpd-php 风格(style)。这样在该目录中的所有文件都会被当作 PHP 来执行。这样就能很方便的将 PHP 文件更名为 .html以隐藏 PHP。
  5. 认证的设置:PHP 认证不能与其它任何类型的认证一起工作。所有认证被传递到 PHP 脚本。要为整个服务器配置 PHP 认证,在默认对象中添加下面一行:

    <Object name="default">
    AuthTrans fn=php4_auth_trans
    .
    .
    .
    </Object>
    
  6. 要在单一目录使用 PHP 认证,添加如下内容:

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

Note:

PHP 使用的堆栈大小取决于 web 服务器的配置。如果运行很大的 PHP 脚本时程序崩溃,推荐在 Admin Server(在“MAGNUS EDITOR”一节)中增大此项。

CGI 环境和对 php.ini 推荐的修改

当编写 PHP 脚本时,应特别注意 Sun JSWS/Sun ONE WS/iPlanet/Netscape 是一个多线程 web 服务器。因此,所有请求都运行在相同的进程空间(Web 服务器自己的空间),该空间仅有一套环境变量。如果想获得 CGI 变量,例如 PATH_INFOHTTP_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 >= 4.3.3)

可以使用 PHP 为 "404 Not Found" 或类似的错误代码生成错误页面。将下面几行添加到 obj.conf 中以覆盖默认的错误页面:

Error fn="php4_execute" code=XXX script="/path/to/script.php" [inikey=value inikey=value...]
XXX 是 HTTP 错误代码。请删除任何可能干扰 Error 设置的指令。如果想为所有可能存在的错误提供一个页面,则将 code 参数删除。脚本可以通过 $_SERVER['ERROR_TYPE'] 获得 HTTP 状态代码。

另一种可能是生成自造目录列表。只要创建一个 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...]
错误和目录列表页面中,原始的 URI 和翻译的 URI 均被分别储存在 $_SERVER['PATH_INFO']$_SERVER['PATH_TRANSLATED'] 变量中。

关于 nsapi_virtual()和子请求的注意事项(PHP >= 4.3.3)

NSAPI 模块现在支持 nsapi_virtual() 函数(别名: virtual()),用来在 web 服务器上创建子请求(subrequests)和在 web 页面插入请求的结果。此函数使用了一些 NSAPI 中还没有文档说明的函数。在 Unix 下,该模块自动查找需要的函数,若它们存在则使用它们。若不存在,函数 nsapi_virtual() 被禁用。

Note:

但是要注意,对 nsapi_virtual() 的支持是试验性质的!

add a note add a note

User Contributed Notes 8 notes

up
1
jedokahn at yahoo dot com at
14 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.
up
0
Lucius Rizzo Lucius dot Rizzo at Has dot Education
5 years ago
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
up
0
Lucius Rizzo
5 years 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 Rizzo
www.say.si
up
0
Brian
11 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
up
0
masochisthalo at yahoo dot com
14 years ago
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
up
0
mark at markround dot com
14 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]
up
-1
ericbackstrom at hotmail dot com
13 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 :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"
up
-1
vijay
13 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?

Thanks
Vijay

官方地址:https://www.php.net/manual/en/install.unix.sun.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3