Sun ONE logo      上一個      目錄      索引      下一個     

Sun ONE Application Server 7 管理員指南

第 7 章
配置 Web 伺服器外掛程式

本章解釋 Sun ONE Application Server 如何處理超文件傳輸協定 (HTTP) 請求,以及如何藉由 Sun ONE Application Server 配置和使用 Web 伺服器外掛程式。還解釋如何藉由 Microsoft IIS 與 Apache Web 伺服器,配置和使用 Web 伺服器外掛程式。

本章包含以下主題:


關於 Web 伺服器外掛程式

Web 伺服器外掛程式是 HTTP 反向代理外掛程式,可讓您指導 Sun ONE Web Server 或 Sun ONE Application Server 將特定的 HTTP 請求轉寄到另一伺服器中。例如,您可以配置連線至網際網路的 Web 伺服器,將針對特定 Web 應用程式的請求轉寄給受公司防火牆保護的應用程式伺服器。

在 Sun ONE Application Server 內,Web 伺服器外掛程式可讓一個伺服器實例將 HTTP (Web) 請求轉寄給另一個伺服器實例。

Web 伺服器外掛程式執行下列功能︰

若要瞭解 Web 伺服器外掛程式的工作方式,則有必要瞭解 HTTP 請求的基本原理,特別是 Sun ONE Application Server 處理 HTTP 請求的方法。


處理用戶端請求

Sun ONE Application Server 是可以直接接受和回應 HTTP 請求的應用程式伺服器。在本節中,我們將論述 HTTP 基本原理並查看 Sun ONE Application Server 處理請求的方式。本章節涵蓋以下主題:

HTTP 基本原理

作為快速摘要,HTTP/1.1 協定的工作方式如下︰

請求包含指示一種方法 (如 GETPOST) 的行、指示所請求資源的一致性資源識別碼 (URI),以及用空格分隔的 HTTP 協定版本。

其後面通常跟隨一些標頭、指示標頭結束的空白行,有時還有內文資料。標頭可能提供關於請求或用戶端內文資料的各種資訊。一般而言,僅針對 POSTPUT 方法發送標頭。

下面顯示的請求範例將由瀏覽器發送,以請求伺服器 foo.com 發回 /index.html 中的資源。在該範例中,由於方法為 GET (請求要點是取得某些資料而非發送資料),因此不發送內文資料。

GET /index.html HTTP/1.0

User-agent:Mozilla

Accept:text/html, text/plain, image/jpeg, image/gif, */*

Host:foo.com

伺服器收到請求並進行處理。雖然伺服器可以同時處理多個請求,但其仍個別地處理每個請求。每個請求的處理都分為連續的多個步驟,一起組成請求處理程序。

伺服器會產生回應,回應包括 HTTP 協定版本、HTTP 狀況碼以及用空格分隔的原因片語。回應後面,通常跟隨一些標頭。標頭結尾用空白行表示。回應的內文資料隨之出現。典型 HTTP 回應之外觀如下所示︰

HTTP/1.0 200 OK

Server:Standard/7.0

Content-type:text/html

Content-length: 83

<HTML>

<HEAD><TITLE>Hello World</Title></HEAD>

<BODY>Hello World</BODY>

</HTML>

狀況碼和原因片語可告知用戶端伺服器是如何處理請求的。通常會傳回狀況碼 200,指示請求處理成功以及內文資料包含請求的項目。其他結果碼指示重新導向至另一個伺服器或瀏覽器的快取記憶體,或各種類型的 HTTP 錯誤 (如「404 未找到」)。

請求處理程序中的步驟

Sun ONE Application Server 初次啟動時,它會執行某些初始化工作,然後等待用戶端 (如瀏覽器) 發出 HTTP 請求。收到請求後,它首先會選取一個虛擬伺服器。

一旦選取了虛擬伺服器,虛擬伺服器的 obj.conf 檔案將指定以下列步驟處理請求的方式︰

  1. AuthTrans (授權轉換)
  2. 確認請求中發送的任何授權資訊 (如名稱和密碼)。

  3. NameTrans (名稱轉換)
  4. 將邏輯 URI 轉換為本機檔案系統路徑。

  5. PathCheck (路徑檢查)
  6. 檢查本機檔案系統路徑的有效性,並檢查請求者是否擁有存取檔案系統上所請求資源的權限。

  7. ObjectType (物件類型)
  8. 決定所請求資源的 MIME 類型 (多用途網際網路郵件編碼) (例如,text/htmlimage/gif 及其他)。

  9. Service (產生回應)
  10. 產生回應並將其傳回至用戶端。

  11. AddLog (加入日誌項目)
  12. 加入項目至日誌檔。

  13. Error (服務)
  14. 僅當前面的步驟中發生錯誤時,才會執行此步驟。如果發生錯誤,伺服器會記錄錯誤訊息並中斷處理程序。


Web 伺服器外掛程式配置

Web 伺服器外掛程式的配置和運作方式由一組配置檔案決定。Sun ONE Application Server 每次處理來自用戶端的請求時,都會查看在這些檔案中定義的配置。配置檔案命名為 obj.confinit.confobj.conf 檔案以虛擬伺服器名稱作為字首,如 server1-obj.conf。如需更多資訊,請參閱 obj.conf 檔案

Sun ONE Application Server 的每個實例都有自己的 init.conf 檔案,在該伺服器啟動時將參考此檔案。

如前面主題所述,obj.conf 配置檔案包含一系列說明 (指令),用以告知 Sun ONE Application Server 在用戶端請求與回應程序的每個階段應該做的工作。每個指令均可呼叫伺服器應用程式功能 (SAF)。

obj.conf 檔案對於 Sun ONE Application Server 的作業是不可缺少的。若透過管理介面變更伺服器,系統會自動更新 obj.conf

init.conf 配置檔案可以設定於初始化期間用來配置伺服器的變數值。在伺服器啟動期間,伺服器將執行在該檔案中指定的配置參數。請參閱「Sun ONE Application Server Configuration File Reference」,以取得更多資訊。

下圖闡明 Web 瀏覽器、前端 Web 伺服器、後端應用程式伺服器與 Web 伺服器外掛程式的 service-passthroughauth-passthrough SAF 之間的關係︰

圖 7-1 Web 瀏覽器、Web 伺服器、應用程式伺服器與 Web 伺服器外掛程式 SAF 之間的關係

下圖顯示 Web 瀏覽器、前端 Web 伺服器、後端應用程式伺服器與 Web 伺服器外掛程式的 service-passthrough 及 auth-passthrough SAF 之間的關係。


Web 伺服器外掛程式 SAF 參考

本節論述下列伺服器應用程式功能 (SAF) 的功能和行為︰

init-passthrough

init-passthrough 功能初始化 Web 伺服器外掛程式。必須先呼叫該功能,然後才能使用 Web 伺服器外掛程式。

範例:

Init fn="load-modules" shlib="c:/plugins/passthrough.dll" funcs="init-passthrough,auth-passthrough,check-passthrough,service-passthrough" NativeThread="no"

Init fn="init-passthrough"

auth-passthrough

auth-passthrough SAF 適用於 AuthTrans-class 指令。

auth-passthrough 功能可檢查進來的 HTTP (web) 請求,以取得以中間伺服器上執行的 service-passthrough 功能編碼的用戶端資訊。用戶端資訊包括︰

若 auth-passthrough 偵測到已編碼的用戶端資訊,它會把請求視為來自發源用戶端的直接請求,而不視為由執行 service-passthrough 的中間伺服器轉寄的請求。

這在兩層部署方案中很有用;

在這種網路架構中,用戶端永遠連線至執行代理外掛程式的前端 Web 伺服器。此 Web 伺服器是將請求轉寄至 Sun ONE Application Server 的伺服器。這表示 Sun ONE Application Server 僅能從代理主機 (在此情況下為 Web 伺服器) 接收請求,而永遠不能直接從用戶端主機接收。這意味著如果應用程式 (部署於兩個防火牆後面的 Sun ONE Application Server 實例上) 查詢用戶端資訊 (如用戶端 IP 位址),應用程式將取得代理主機 IP (由於它是針對中繼請求的實際發源主機)。auth-passthrough SAF 可用於修改此行為,以便提供遠端 (代理的) 用戶端資訊。

由於 auth-passthrough 可能置換可以用於認證的資訊 (例如,產生請求的 IP 位址),因此,必須僅使用可信賴的用戶端或伺服器連線至執行 auth-passthrough 的伺服器。作為預防措施,建議僅使用公司防火牆後面的伺服器執行 auth-passthrough。可透過網際網路存取的伺服器不應該執行 auth-passthrough SAF。僅當需要關於發源用戶端的相關資訊時,才應該使用 auth-passthrough SAF。

請注意,在上述方案中,SSL 用戶端認證只能對 Web 伺服器「開啟」,對應用程式伺服器永遠「關閉」,如此才可讓配置正常執行。

指令範例︰

AuthTrans fn="auth-passthrough"

service-passthrough

service-passthrough SAF 適用於 Service-class 指令。

service-passthrough SAF 可將請求從一個伺服器轉寄至另一個伺服器,以進行處理。可以配置 service-passthrough SAF 使用針對遠端伺服器的 SSL 或非 SSL (HTTPS 或 HTTP) 連線,而不管用來接收原始請求的連線類型如何。service-passthrough SAF 可以對發源用戶端的相關資訊進行編碼 (遠端伺服器上執行的 auth-passthrough 功能可能會對其解碼)。

service-passthrough 指令一般與 obj.conf 配置檔案中的其他指令結合起來使用,如下所述︰

<Object name="passthrough">

ObjectType fn="force-type" type="magnus-internal/passthrough"

Error reason="Bad Gateway" fn="send-error" uri="$docroot/badgateway.html"

</Object>

<Object name="default">

....

NameTrans fn="assign-name" from="(/webapp1|/webapp1/*)" name="passthrough"

...

</Object>

如果後端應用程式伺服器當機,使用者將看到本機 HTML 檔案 badgateway.html。假使執行 service-passthrough SAF 的伺服器需要提供其可存取的檔案,並且僅僅將拒絕的請求轉寄給後端應用程式伺服器,則 ObjectType 行會變更為︰

ObjectType fn="check-passthrough" type="magnus-internal/passthrough"

check-passthrough

check-passthrough SAF 適用於 ObjectType-class 指令。

check-passthrough 功能用於檢查在本機伺服器上可否取得所請求的資源 (例如 HTML 文件或 GIF 影像)。如果所請求的資源在本機不存在,check-passthrough SAF 將設定類型以指示應該將請求傳送至另一個伺服器,以便由 service-passthrough SAF 處理。

參數︰

type - (可選) 當請求資源不存在時要設定的類型。預設值為「magnus-internal/passthrough」。

範例

ObjectType fn="check-passthrough"


使用 Web 伺服器外掛程式

若要在 Sun ONE Web Server 上使用 Web 伺服器外掛程式,您必須變更 Sun ONE Application Server 和 Sun ONE Web Server 的配置檔案。請遵循本節中所列的程序配置並使用 Sun ONE Web Server 外掛程式:

對 Sun ONE Web Server 的變更

備份重要的配置檔案,例如 magnus.confobj.conf,然後再對其進行變更。

  1. 在 Web 伺服器安裝區域中建立一個目錄,以包含通道外掛程式。 例如︰
  2. cd /webserver_install_dir/plugins

    mkdir -p passthrough/bin

  3. 將 Sun ONE Application Server 的通道外掛程式複製到這個新的 Web 伺服器目錄。例如︰
  4. cd appserver_install_dir/lib

    cp libpassthrough.so webserver_install_dir/plugins/passthrough/bin

    對於 Windows,請複製 passthrough.dll 檔案。

  5. 編輯 magnus.conf 檔案 (位於 webserver_install_dir/https-host.domain/config 下),加入以下行:
  6. Init fn="load-modules" shlib="webserver_install_dir/plugins/passthrough/bin/libpassthrough.so" funcs="init-passthrough,auth-passthrough,check-passthrough,service-passthrough" NativeThread="no"

    Init fn="NSServletEarlyInit" EarlyInit=yes

    Init fn="NSServletLateInit" LateInit=yes

    Init fn="init-passthrough"

  7. 編輯 obj.conf 檔案 (位於 webserver_install_dir/https-host.domain/config 下),並增加 NameTrans 指令,如下所示:
  8. <Object name=default>
    NameTrans fn="NSServletNameTrans" name="servlet"
    NameTrans fn="assign-name" from="/*" name="passthrough"
    </Object>

    from="/*" URI 是在遠端伺服器上部署的 Web 應用程式的環境根,通道對應於 obj.conf 中 <Object> 的名稱。

    例如︰

    <Object name="default">
    ...
    NameTrans fn="assign-name" from="(/webapp1|/webapp1/*)" name="passthrough"
    ...
    </Object>

  9. obj.conf 檔案中增加以下行:
  10. <Object name="passthrough">
    ObjectType fn="force-type" type="magnus-internal/passthrough"
    PathCheck fn="deny-existence" path="*/WEB-INF/*"
    Service type="magnus-internal/passthrough" fn="service-passthrough"
    servers="http://servername:port"
    Error reason="Bad Gateway" fn="send-error" uri="$docroot/badgateway.html"
    </Object>

  11. 重新啟動 Sun ONE Web Server 實例。

下一步,您必須配置 Sun ONE Web Server,以將請求路由至 Web 伺服器外掛程式。

對 Sun ONE Application Server 的變更

備份重要的配置檔案,例如 magnus.confobj.conf,然後再對其進行變更。

  1. 編輯 install_dir/domains/domain1/server1/config/init.conf 檔案,加入以下行:
  2. 在 UNIX 上︰

    Init fn="load-modules" shlib="webserver_install_dir/plugins/passthrough/bin/libpassthrough.so"
    funcs="init-passthrough,auth-passthrough,check-passthrough,service-passthrough" NativeThread="no"
    Init fn="init-passthrough"

    在 Windows 上︰

    Init fn="load-modules" shlib="c:/install_dir/bin/passthrough.dll" funcs="init-passthrough,auth-passthrough,check-passthrough, service-passthrough" NativeThread="no"
    Init fn="init-passthrough"

  3. 編輯 install_dir/domains/domain1/server1/config/server1-obj.conf,並增加 AuthTrans 指令,如下所示︰
  4. <Object name="default">
    AuthTrans fn="match-browser" browser="*MSIE*" ssl-unclean-shutdown="true" AuthTrans fn="auth-passthrough"
    fn="service-passthrough" servers="server"
    Error reason="Bad Gateway" fn="send-error" uri="$docroot/badgateway.html"
    </Object>

    伺服器是下列格式的 URL︰

    http://servername:port

  5. 重新啟動 Sun ONE Application Server 實例。

這將完成您需要對 Sun ONE Application Server 所作的變更。先前說明過的程序是配置應用程式伺服器的單一實例。若要啟動使用 Web 伺服器外掛程式的更多實例,您必須在這些應用程式伺服器實例的配置檔案中進行這些變更。


對於 Solaris 和 Linux,外掛程式庫名稱將為 libpassthrough.so。對於 Windows,外掛程式庫名稱將為 passthrough.dll



配置 Microsoft IIS 以使用 Web 伺服器外掛程式

配置 Microsoft 網際網路資訊服務以使用 Web 伺服器外掛程式,包括配置 Web 伺服器外掛程式以用於 Microsoft IIS,以及配置 Microsoft IIS 以使用 Web 伺服器外掛程式。

您也可以配置伺服器儲存區以處理在不同伺服器上執行的多重應用程式。

本章節涵蓋以下主題:

配置用於 IIS 的 Web 伺服器外掛程式

若要配置用於 IIS 的 Web 伺服器外掛程式,請執行下列工作︰

  1. 於 IIS wwwroot 目錄下,為 Web 伺服器外掛程式建立一個目錄,方法為從 C:\ 指令行提示處鍵入以下指令︰
  2. md \Inetpub\wwwroot\sun-passthrough

  3. 將外掛程式檔案複製到 C:\Inetpub\wwwroot\sun-passthrough 目錄下。
  4. 使用文字編輯程式,將機器 (已安裝 Sun ONE Application Server) 的 URL 加入至 C:\Inetpub\wwwroot\sun-passthrough\sun-passthrough.properties 檔案。
  5. 您需要藉由文字編輯程式加入以下資訊︰

    server=http://appservername:port

    其中,appservername 是機器 (已安裝 Sun ONE Application Server) 的主機名稱或 IP 位址,port 是機器進行偵聽時所在連接埠的號碼 (該值通常設定為 80)。

  6. C:\Inetpub\wwwroot\sun-passthrough\sun-passthrough.properties 檔案中,列示您想讓 Sun ONE Application Server 提供的環境根。
  7. 這些環境根應該與 Sun ONE Application Server 上部署的應用程式環境根相符。對這些環境根的請求將由 Sun ONE Application Server 接受並處理,而其他請求由 IIS Web 伺服器處理。將請求傳送給 Web 應用程式的指令行為︰

    passthrough=/webapplication

    其中,/webapplication 是 Web 應用程式的環境根。若要將所有請求傳送至 Sun ONE Application Server,請增加以下行︰

    passthrough=/

現在,您已在 Microsoft IIS 根目錄中配置了 Web 伺服器外掛程式。若要完成程序,您現在需要配置 Microsoft IIS 使用 Web 伺服器外掛程式。

配置 IIS 以使用 Web 伺服器外掛程式

若要配置 IIS 使用 Web 伺服器外掛程式,您需要開啟 Windows 網際網路服務管理程式。網際網路服務管理程式位於 [控制台] 資料夾內的 [管理工具] 資料夾中。

開啟網際網路服務管理程式,並執行下列工作︰

  1. 選取您要為之啟用外掛程式的網站。該網站通常被命名為「預設網站」。
  2. 以滑鼠右鍵按一下網站,選取 [內容] 以開啟 [內容] 筆記本。
  3. 開啟 [ISAPI 過濾器] 標籤,按一下 [新增] 按鈕,並執行以下步驟,以加入新的 ISAPI 過濾器︰
    1. 在 [過濾器名稱] 欄位中,輸入 Sun ONE Application Server
    2. 在 [可執行] 欄位中,鍵入 C:\Inetpub\wwwroot\sun-passthrough\sun-passthrough.dll
    3. 按一下 [確定],關閉 [內容] 筆記本。
  4. 您現在需要建立和配置新的虛擬目錄。執行以下步驟以建立和配置新的虛擬目錄︰
    1. 以滑鼠右鍵按一下預設網站,選取 [新建],然後選取 [虛擬目錄]。[虛擬目錄建立精靈] 將開啟。
    2. 在 [別名] 欄位中,鍵入 sun-passthrough
    3. 在 [目錄] 欄位中,鍵入 C:\Inetpub\wwwroot\sun-passthrough
    4. 請確定您核取了 [執行許可權] 核取方塊,並且所有其他許可權核取方塊均未核取。
    5. 按一下 [完成]。
  5. 您需要停止並啟動 Web 伺服器,才能讓新設定生效。若要停止 Web 伺服器,請以滑鼠右鍵按一下網站並選取 [停止]。若要啟動 Web 伺服器,請以滑鼠右鍵按一下網站並選取 [啟動]。
  6. 然後,在 Web 瀏覽器中鍵入以下內容,以存取 Web 應用程式環境根︰

    http://webservername/webapplication

    其中,webservername 是 Web 伺服器的主機名稱或 IP 位址,/webapplication 是您在 C:\Inetpub\wwwroot\sun-passthrough\sun-passthrough.properties 檔案中列示的環境根,以確認 Web 伺服器、Web 伺服器外掛程式以及 Sun ONE Application Server 正常作業。

配置多重伺服器儲存區

sun-passthrough.properties 檔案中配置伺服器儲存區,便可能跨多重應用程式伺服器分割 Web 應用程式 (即,您在一組伺服器上執行某些應用程式,在另一組伺服器上執行其他應用程式)。對於每個伺服器儲存區,請選擇唯一名稱,包含字母和數字。一旦您完成為 Microsoft IIS 安裝和配置 Web 伺服器外掛程式的步驟,如配置 Microsoft IIS 以使用 Web 伺服器外掛程式一節所述,便可編輯 C:\Inetpub\wwwroot\sun-passthrough\sun-passthrough.properties 檔案,並將您為伺服器儲存區選擇的唯一名稱作為相關伺服器和 passthrough 特性行的字首。在伺服器儲存區名稱後放置一個小數點 (.)。

例如,sun-passthrough.properties 檔案中的下列行可定義兩個伺服器儲存區。第一個伺服器儲存區包含 server-a 以及對環境根 /app1 的服務請求。第二個伺服器儲存區包含 server-b 以及對環境根 /app2/app3 的服務請求。

server=http://server-a

passthrough=/app1

serverpool2.server=http://server-b

serverpool2.passthrough=/app2

serverpool2.passthrough=/app

sun-passthrough.properties 檔案範例

# Sun ONE Application Server web server plugin for IIS

#

# This file is used to configure the Sun ONE Application Server web server

# plugin for IIS.Lines beginning with a '#' are ignored.

# server

#

# The server property specifies the URL of an application server.If multiple

# server properties are given, the plugin will distribute load across the

# specified application servers.

#

server=http://localhost:8080

# passthrough

#

# The passthrough property specifies the context root (virtual directory) of a

# web application.Requests for the given context root will be passed to the

# application server for processing.If 'passthrough=/' is specified, all

# requests will be passed to the application server for processing.

#

# passthrough properties should be ordered from most to least specific.For

# example, 'passthrough=/apps/app1' should appear before 'passthrough=/apps'.

#

# Multiple passthrough properties are allowed.

#

#passthrough=/webapp

#passthrough=/servlets

#passthrough=*.jsp

passthrough=/

# prefix

#

# The prefix property specifies the IIS virtual directory that contains the

# plugin DLL, sun-passthrough.dll.

#

prefix=/sun-passthrough

# error-url

#

# The error-url property specifies the URL of a page to redirect the client to

# when the application server is unavailable.

#

#error-url=/badgateway.htm

# It is possible to configure multiple server pools by prefixing the server

# and passthrough property names with a pool name followed by a period ('.').

# Pool names can be any sequence of letters and numbers.

#

# For example, the following properties define two server pools.One server

# pool will service the web applications at '/app1' and the other will service

# the web applications at '/app2' and '/app3':

#

#serverpool1.server=http://server-a

#serverpool1.passthrough=/app1

#

#serverpool2.server=http://server-b

#serverpool2.passthrough=/app2

#serverpool2.passthrough=/app3


配置 Apache Web 伺服器

本節說明您如何才能編譯 Apache 來源碼以及配置 Apache Web 伺服器的安裝,以使用 Sun ONE Application Server。

若要啟動要傳送至 Sun ONE Application Server 的 HTTP 請求,您必須編譯 Apache 來源,以使用 mod_proxy 模組,然後修改 httpd.conf 檔案。

本節包含有關以下程序的資訊︰

最低需求

您必須滿足以下需求,才能成功編譯 Apache Web 伺服器並使用 mod_proxy 外掛程式。

使用 mod_proxy 模組編譯 Apache

  1. www.apache.org 下載帶有內建 mod_proxy 模組的最新 Apache 來源分配
  2. 解壓縮來源分配來源分配以壓縮的歸檔檔案形式提供。如果您安裝 Apache 1.3.27,來源分配歸檔檔案將讀取 apache_1.3.27.tar.gz

  3. 使用以下指令,對歸檔檔案進行解壓縮並解除磁帶存檔︰
  4. $ tar -zxvf apache_1.3.27.tar.gz

    該指令將在目前的工作目錄下建立稱為 apache_1.3.27 的目錄。

  5. 您現在需要配置您的環境以編譯 Apache 來源碼。來源分配隨附一個稱為 configure 的程序檔,該程序檔可檢查您的環境是否具有順利編譯 Apache 所必需的支援檔案 (如標頭、共用程式庫和公用程式)。
  6. 若要配置您的環境,請移往 Apache 來源目錄,並繼續執行下列步驟︰

    1. 確定下列路徑存在,同時在 Solaris 上安裝 Apache︰
      • CC=/opt/SUNWspro/bin/cc

        其中 /opt/SUNWspro/bin 是安裝 cc 的路徑。確定它位於您的 PATH 中。

      • 確定 /usr/ccs/bin 位於您的 PATH 中。
    2. 執行以下指令:
    3. ./configure --enable-module=proxy --prefix=/usr/local/apache

      prefix 引數中指定的路徑指出您要安裝 Apache 的位置。這是一個變數,您可以指定要安裝 Apache 的路徑。

      該指令將在螢幕上輸出數行。實質上,該指令會依據您的系統配置為建構建立 Makefiles。如果 configure 發生錯誤,您可能遺漏了某些標頭檔案或公用程式 (必須首先安裝才能繼續執行)。

  7. configure 程序檔成功執行後,您可以使用 make 指令編譯 Apache,如下所述︰
  8. make

    該指令將在螢幕上輸出數行,指示程序正在編譯 Apache 來源碼並連結 Apache。此程序應該正常結束,無任何錯誤。不過,如果發生錯誤,請檢查是否已正確下載 Apache 的所有程式庫檔案和公用程式。

  9. 您現在需要安裝 Apache。Apache 在 /usr/local/apache 目錄下 (或您指定的任何其他目錄) 安裝其本身。若要安裝 Apache,請執行以下指令︰
  10. make install

    如果該指令執行成功,則您的系統現已安裝了 Apache。您應該查看以下目錄中的 Apache 安裝檔案︰

    /usr/local/apache

    主配置檔案 (稱為 httpd.conf) 將安裝於 /usr/local/apache/conf 目錄下。


    mod_proxy 缺少 Sun ONE Application Server 7 反向代理外掛程式的 SSL 傳輸和載入平衡功能。使用 mod_proxy 時,Web 應用程式也無法取得用戶端的 IP 位址或 SSL 用戶端憑證。


修改 httpd.conf 檔案

透過檔案 httpd.conf 配置 Apache。該檔案包含一些 Apache 指令,這些指令可決定 Apache 伺服器的各種作業參數。若要執行 Apache 的簡單安裝,您需要修改下列幾個指令︰

ServerRoot “/usr/local/apache”
Port 5000

ServerRoot 是您安裝 Apache 的路徑。

現在已配置了 Apache 的預設行為和 Web 服務。下一步,您必須將下列應用程式伺服器特定的指令加入至 httpd.conf 檔案以啟動 Apache,將 HTTP 請求轉寄給 Sun ONE Application Server︰

<IfModule mod_proxy.c>
ProxyPass / http://<s1as_server.some.domain>:<port>/
ProxyPassReverse / http://<s1as_server.some.domain>:<port>/
</IfModule>

在這裡,應該將 <s1as_server.some.domain>:<port> 替代成您的 Sun ONE Application Server 之 URL 位址。複製這兩行以用於每個 Web 應用程式環境根,其中 /application 是 Web 應用程式環境根,http://server 是 Sun ONE Application Server 的 URL。

這將完成 Apache Web 伺服器的配置。

啟動與停止 Apache

Apache 隨附一個標題為 apachectl 的程序檔,該程序檔可讓啟動、停止和重新啟動 Apache 更容易。執行以下指令以啟動 Apache

$ /usr/local/apache/bin/apachectl start

若要停止 apache,請執行以下指令︰

use /usr/local/apache/bin/apachectl stop

啟動後,您可以測試 Apache 的安裝。Apache 執行後,請在您的 Web 瀏覽器中鍵入以下位址︰http://localhost/.如果您的安裝成功並且 Apache 執行,您應該可以看到顯示有關成功訊息的測試頁面。



上一個      目錄      索引      下一個     


Copyright 2003 Sun Microsystems, Inc. 。版權所有。