一、基本原理 Netscape Enterprise Server以兩種方式執(zhí)行CGI程序. - 指定一僅包含CGI程序的目錄,所有在該目錄下的程序不管是是什么后綴名都被執(zhí)行
- 指定以某種后綴名結(jié)尾的程序均為CGI程序,放在服務(wù)器的任何位置都會被執(zhí)行,PHP程序以該方式執(zhí)行。
在mime.types中包含magnus-internal/cgi bat,cgi,exe,這告訴Netscape Enterprise Server后綴名為bat,cgi,exe的程序其類型為magnus-internal/cgi,但默認情況下如果這些程序不放在指定的CGI程序目錄下Netscape Enterprise Server將不會執(zhí)行它們。可以通過Netscape Enterprise Server Manager|Progams|CGI File Type,把Activate CGI as a file type選為Yes,然后Save and apply后即可。這樣以bat,cgi,exe結(jié)尾的程序放在任何地方都會被執(zhí)行。 實際上手工在obj.conf文件中添加 Service type="magnus-internal/cgi" fn="send-cgi" 即可。 在Netscape Enterprise Server上執(zhí)行PHP程序需要一plugin程序模塊,在啟動Netscape Enterprise Server時 會啟動該模塊,當(dāng)客戶端請求PHP程序時該模塊會告訴Netscape Enterprise Server,這是個magnus-internal/cgi 類型的文件,因此該PHP程序就被執(zhí)行。 為實現(xiàn)以上功能,在obj.conf文件中加入 Init fn="load-modules" funcs="redirect-cgi" \ shlib="/opt/local/suitespot-3.0/plugins/redirect/redirect_cgi.so" NativeThread="no" 在啟動Netscape Enterprise Server時啟動該模塊。 和 ObjectType fn="redirect-cgi" cgi_path="/opt/local/www/cgi-bin/php" type="magnus-internal/php" 通過先前啟動的plugin模塊告訴Netscape Enterprise Server,類型為magnus-internal/php的文件, 需通過/opt/local/www/cgi-bin/php來解釋執(zhí)行。 在mime.types中加入一行 magnus-internal/php php3,phtml 后,Netscape Enterprise Server就知道如何處理后綴名為php3,phtml的文件了。 二、具體實現(xiàn)步驟: - 從http://www.webgenx.com/php/phpnes.php3下載原程序后,參考$NETSCAPE_HOME/nsapi/examples目錄下的Makefile文件,編譯生成redirect_cgi.so文件。
- 把該文件放置在某一目錄下,例如:/opt/local/suitespot-3.0/plugins/redirect/redirect_cgi.so。
- 修改mime.types文件加入magnus-internal/php php3,phtml。
- 修改obj.conf,在其它的Init-directives后,加入
Init fn="load-modules" funcs="redirect-cgi" \ shlib="/opt/local/suitespot-3.0/plugins/redirect/redirect_cgi.so" NativeThread="no" - 修改obj.conf
在ObjectType fn="type-by-extension"和ObjectType fn="force-type" type="text/plain"間加入: ObjectType fn="redirect-cgi" cgi_path="/opt/local/www/cgi-bin/php" type="magnus-internal/php"。 - 修改obj.conf
在ObjectType fn="force-type" type="text/plain"和 Service method="(GET|HEAD)" type="magnus-internal/imagemap" fn="imagemap"間加入 Service type="magnus-internal/cgi" fn="send-cgi"。 - 把編譯后生成的php文件放在/opt/local/www/cgi-bin目錄下。
完成后重新啟動Netscape Enterprise Server即可。 |