在 Windows 上安裝供 localhost 使用的 Apache

| | Comments (0) | TrackBacks (0)
這篇文章記述的是:如何在 Windows 上安裝一個僅供 localhost (本機電腦)使用的 Apache 網頁伺服器。

相關軟體版本如下:
  • Windows XP SP2 繁體中文版
  • Apache 2.2.6

安裝

Apache 官方網站 下載 Windows 上的安裝檔。這要到鏡像網站上稍微找一下(比方說:這裡)。

我們這次下載的檔案名稱是 apache_2.2.6-win32-x86-no_ssl.msi 。

執行安裝程式,會出現一系列的對話盒要你填寫設定值。以下沒特別提醒的部份請選擇預設值、或憑常識判斷。

  • Server Information
Network Domain 與 Server Name 都填 localhost 即可。Admin 的 email 可以填 admin@localhost 。

設定準備

安裝目錄預設是 C:\Program Files\Apache Software Foundation\Apache2.2\ 。
(基本上這路徑沒必要更改)

你必須要指定一個網頁文件根目錄。如果沒更改的話會是安裝目錄下的 htdocs 目錄,可是這樣很不方便,還是另外指定一個的好。
我們假設指定的路徑是 D:\WebRoot 。讓我們先在這個目錄裡新增一個名為 index.html 的檔案,內容就寫 Hello World 好了。

設定步驟

在安裝目錄下找到 conf\httpd.conf ,這是 Apache 的組態設定檔,請用文字編輯器開啟。

  • 尋找 Listen 80 ,將之改為 Listen 127.0.0.1:80 。
  • 尋找 DocumentRoot ,應該會找到兩個地方。將這兩處找到的 C:/Program Files/Apache Software Foundation/Apache2.2/htdocs 改為 D:/WebRoot 。注意目錄的分隔字元是正斜線 / ,而非 Windows 環境下常見的反斜線 \ 。
在 Windows 左下角(時鐘旁邊)找到 Apache Monitor 的圖示。停止 Apache service 之後再次啟動(於是 Apache 會重新載入設定檔)。

打開任意瀏覽器,輸入網址 http://localhost/ ,你應該可以順利看到你的 index.html 頁面。

0 TrackBacks

Listed below are links to blogs that reference this entry: 在 Windows 上安裝供 localhost 使用的 Apache.

TrackBack URL for this entry: http://www.caiyutw.com/mtype/mt-tb.cgi/1

Leave a comment

About this Entry

This page contains a single entry by 采豫 published on October 30, 2007 10:28 PM.

I just finished installing Movable Type 4.01! was the previous entry in this blog.

HiNet 的 Transparency Proxy 和 phpBB 的關係 is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Powered by Movable Type 4.01