天天看點

windows環境下安裝apache及使用apache搭建反向代理

一、配置Apache平台軟體

1、下載下傳apache軟體

2、方法/步驟如下:

<a href="http://s3.51cto.com/wyfs02/M01/4B/41/wKiom1Qo-NWDX3lzAAa13MPPzVQ075.jpg" target="_blank"></a>

2.1、進入apache伺服器官網http://httpd.apache.org/,這裡我們以下載下傳穩定版的httpd 2.2.29為例,點選download。

2.2、download.cgi頁面,往下翻找到2.2.29版本,其中有兩個下載下傳選項

     Source: httpd-2.2.29.tar.gz [ PGP ] [ MD5 ] [ SHA1 ]

     Source: httpd-2.2.29.tar.bz2 [ PGP ] [ MD5 ] [ SHA1 ]

但這兩個是類unix系統下安裝的安裝包,不是我們要的。這裡我們點選Other files。

<a href="http://s3.51cto.com/wyfs02/M01/4B/44/wKioL1Qo-YDwIvfTAAMWIXQVoPs483.jpg" target="_blank"></a>

也就是剛剛那兩個都是沒有經編譯的源碼,要下載下傳相應已編譯的平台需要去binaries下載下傳,這裡點選旁邊的binaries連結即可。

<a href="http://s3.51cto.com/wyfs02/M00/4B/44/wKioL1Qo-j6Dh5HtAAOESeMY3ZQ100.jpg" target="_blank"></a>

2.4、點選win32即可。

<a href="http://s3.51cto.com/wyfs02/M02/4B/44/wKioL1Qo-r2h8lPtAARr47tIwc4795.jpg" target="_blank"></a>

2.5、點進去之後,32位windows的http server 2.2.25分别帶ssl和不帶ssl功能的版本,根據需要選擇一個即可,下面還有ftp的插件可以下載下傳

<a href="http://s3.51cto.com/wyfs02/M00/4B/42/wKiom1Qo-z_DFGnbAAQdC_6lZwM643.jpg" target="_blank"></a>

二、windows環境下安裝apache服務

1、安裝apache軟體:

a、運作安裝軟體,歡迎界面,直接點next。

<a href="http://s3.51cto.com/wyfs02/M02/4B/42/wKiom1Qo_WjRUm9eAAG2Dl0tUAk184.jpg" target="_blank"></a>

b、協定,同意,點next。

<a href="http://s3.51cto.com/wyfs02/M02/4B/42/wKiom1Qo_ePDr0M8AAIAo32Bidk753.jpg" target="_blank"></a>

點next

<a href="http://s3.51cto.com/wyfs02/M01/4B/42/wKiom1Qo_gvzs6rpAAJ5SyAtqUM241.jpg" target="_blank"></a>

c、基本配置資訊,都是用于錯誤資訊提示的相關資訊:前兩個伺服器相關資訊,如果有固定的域名,例如www.baidu.com,則第一行寫baidu.com,第二行寫www.baidu.com;否則兩個都寫localhost;第三行填寫管理者郵箱位址(這是我自己的郵箱),其他按圖檔中的方式填寫!!!

<a href="http://s3.51cto.com/wyfs02/M01/4B/43/wKiom1Qo_yPyRuC7AAG7PW3_j4A506.jpg" target="_blank"></a>

d、典型或自定義安裝。這裡我選擇第一個典型安裝,next。

<a href="http://s3.51cto.com/wyfs02/M01/4B/45/wKioL1QpAGuTqnPpAAFunO6xVzI757.jpg" target="_blank"></a>

e、路徑改成自己設定的位址,必須全英文,不要放在網站位址裡面哦!

<a href="http://s3.51cto.com/wyfs02/M00/4B/43/wKiom1QpAIbg01BFAAEwnM4KYvo298.jpg" target="_blank"></a>

f、安裝Install

<a href="http://s3.51cto.com/wyfs02/M01/4B/45/wKioL1QpAXGB_bEQAAErWk8XQvI639.jpg" target="_blank"></a>

g、開始安裝,請耐心等待。

<a href="http://s3.51cto.com/wyfs02/M01/4B/43/wKiom1QpAUeh4fimAAFBYTcdkNQ734.jpg" target="_blank"></a>

h、安裝完成,Finish。

<a href="http://s3.51cto.com/wyfs02/M02/4B/43/wKiom1QpAXHyZi5tAAFnB2zVZ8c130.jpg" target="_blank"></a>

I、apache服務啟動、停止、重新開機

<a href="http://s3.51cto.com/wyfs02/M02/4B/43/wKiom1QpAtmTU4R3AAHceIiJwK0264.jpg" target="_blank"></a>

到些apache安裝完成。

三、windows下使用apache搭建反向代理

1、安裝Apache,并使其能正常工作

2、打開httpd.conf,找到以下幾個Module并将其啟用(如果沒有,可以自行添加)

    mod_proxy.so(module_proxy) 

    mod_proxy_http.so(module_proxy_http)                 

    mod_cache.so(module_cache) 

    mod_disk_cache.so(module_disk_cache) 

3、參考以下VirtualHost段,進行設定:                

    &lt;VirtualHost *:8081&gt; 

       ServerName 10.75.123.1    //本地伺服器内網位址 

       ProxyPass /test http://10.75.123.1:8080/test

       ProxyPassReverse /test http://10.75.123.1:8080/test

       ProxyPass /testm http://10.75.123.2:8089/testm 

       ProxyPassReverse /testm http://10.75.123.2:8089/testm

#下面這幾段可以加也可不加,看需求                

    #  CacheRoot "d:/apache_cache/"                   

    #  CacheEnable disk /images/                   

    #  CacheDirLevels 2                   

    #  CacheDirLength 1                

    &lt;/VirtualHost&gt; 

    其中,ProxyPass和ProxyPassReverse代表原始位址,CacheRoot為緩存目錄,需要自行建立,并給Apache程序所在的使用者配置設定NTFS權限,CacheEnable後的第一個參數disk表示用磁盤進行緩存,/images/ 表示需要緩存的目錄,如果直接設定為/,可能導緻動态腳本被緩存,那就失去了本身的意義。可以添加多個CacheEnable以緩存多個目錄。CacheDirLevels和CacheDirLength一般不需要修改,這個表示緩存目錄中資料目錄的級數和目錄名長度。 

    網頁通路輸入公網的域名或IP位址,上面的apache是用的8081的端口,那麼外網把8081的端口放開才能通路。例如公網位址是221.224.89.220,開放端口是8081,通路如下所示:

http://221.224.89.220:8081/test

      本文轉自ling118 51CTO部落格,原文連結:http://blog.51cto.com/meiling/1559416,如需轉載請自行聯系原作者