PHP Velho Oeste 2024

Sun, iPlanet, Netscape サーバー(Sun Solaris 用)

このセクションでは、Sun Solaris 上の Sun Java System Web Server, Sun ONE Web Server, iPlanet and Netscape server に PHP をインストールする際の 手引きと注意事項について説明します。

PHP 4.3.3 より、NSAPI モジュール を使って 独自エラーページ および ファイル一覧表示ページの生成 が可能です。 Apache 互換の関数も追加されています。 また、これらの Web サーバーについての サブリクエストに関する注意 も参照してください。

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=.:/usr/local/bin:/usr/sbin:/usr/bin:/usr/ccs/bin )。 そして、export PATHとし、パスを有効にします。
  3. gunzip php-x.x.x.tar.gz (.gz 配布の場合のみ)
  4. tar xvf php-x.x.x.tar
  5. PHP を展開したディレクトリに移動します cd ../php-x.x.x
  6. 以下のステップを実施します。 /opt/netscape/suitespot/ は netscape サーバーがインストールされている場所です。 異なる場合は、適切なパスに変更してください。

    ./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に次の行を追加します (administration server で行えます。)

    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 パラメータはオプションですが、 これを指定することにより、Web サーバーの設定ファイルがあるフォルダに php.ini を置くことが可能になります。

  3. obj.conf のデフォルトオブジェクトを設定します (バージョン 6 以降の仮想サーバーの場合は 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) 追加のパラメータとして、いくつかの特別な php.ini 値を 追加することができます。例えば、コンテキスト php4_execute に対して docroot="/path/to/docroot" を設定するなどです。 また、論理値の場合、0/1 を値として使用してください。 "On","Off",... では正しく動作しません。 例えば、zlib.output_compression="On" ではなく、 zlib.output_compression=1 とします。

  4. 以下は、(cgi-bin ディレクトリ のように) PHP スクリプトだけが置かれるディレクトリを設定したい場合にのみ必要です。

    <Object name="x-httpd-php">
    ObjectType fn="force-type" type="magnus-internal/x-httpd-php"
    Service fn=php4_execute [inikey=value inikey=value ...]
    </Object>
    
    こうしておくと、Administration Server に特定のディレクトリを設定し、 これをスタイル x-httpd-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>
    

注意:

PHP が使用するスタックサイズは Web サーバーの設定に依存します。 非常に大きい PHP スクリプトを実行させた際にクラッシュが発生する場合は、 Administration Server でスタックサイズ("MAGNUS EDITOR") を大きくすると良いでしょう。

CGI 環境変数と php.ini の変更

Sun JSWS/Sun ONE WS/iPlanet/Netscape がマルチスレッドの Web サーバーだという事が PHP スクリプトを書く際に重要になります。すべてのリクエストは同一の (Web サーバー自体の)プロセス空間で実行され、そのプロセス空間は 1 つの環境変数しか 持っていません。PATH_INFOHTTP_HOST CGI 変数を取得する場合、 古い PHP で行っていたような方法、つまり getenv() 関数を使用する方法や他の同等な方法 (グローバル変数の登録機能、 $_ENV 等)を使うのは正しい方法ではありません。 Web サーバーの環境変数をただ単に取得するだけと、 正しい CGI 変数は得られないのです。

注意:

なぜ正しくない CGI 変数が登録されているのでしょうか?

それは、Web サーバーのプロセスを Administration Server から起動させる際、 Web サーバーの起動スクリプトが CGI スクリプトとして実行されるためです。したがって、 起動された Web サーバーの環境変数には CGI 変数も含まれることになります。 Administration Server 以外から Web サーバーを起動してみればこのことをテストできるでしょう。 ルートユーザーでコマンドラインを使って、手動で起動してみると、CGI 変数らしき 環境変数が登録されないことが確認できるでしょう。

PHP 4.x のスクリプトで CGI 変数を取得する場合は、スーパーグローバル $_SERVER を用いるのが正しい方法です。また、$HTTP_HOST などを使う古いスクリプトを使用する場合は、php.iniregister_globals をオンにし、変数のパースの順番 (variables_order) を変更してください ("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 パラメータを省略してください。スクリプトで HTTP ステータス コードを取得するには、 $_SERVER['ERROR_TYPE'] を使用します。

独自のファイル一覧表示ページを PHP を使って生成することも可能です。 ファイル一覧表示を行う PHP スクリプトを作成し、obj.conftype="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 サーバーへサブリクエストを行い、結果を Web ページへ挿入することができます。 ただし、この関数は NSAPI ライブラリの文書化されていない機能を若干使用しています。 モジュールは、自動的に必要な関数群を探し、可能であればそれらの関数を 使用ます。もし使用可能でなければ、nsapi_virtual() 関数は 使用不可となります。

注意:

nsapi_virtual() サポートは「実験的」な機能です。

add a note add a note

User Contributed Notes 8 notes

up
1
Lucius Rizzo
10 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
1
Brian
16 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
1
jedokahn at yahoo dot com at
19 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
10 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
mark at markround dot com
19 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
18 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
masochisthalo at yahoo dot com
19 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
-2
vijay
18 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
To Top