配置前資料檢查:
1.可以使用的apache
安裝apache服務:打開cmd , 在apache的bin目錄下執行以下命令
httpd -k install -n apache2.2 其中"apache2.2"是服務名,視情況而定(要看你的apache版本)
2.你的部署任務中是否給了靜態文件(即:網頁文件),配置中需要文件的路徑
3.網路是否通暢,另外關閉window防火牆
開始配置
進入apache的conf 文件夾內,找到http.conf文件,配置apache
關鍵配置點
1.Listen 80 監聽端口 一半默認為80
可以在cmd輸入命令 net stat -ano 檢查端口是否占
2.
<Directory "path">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
path 為靜態文件所在路徑
allow from all,默認是deny from all 要改成allow
3.NameVirtualHost *:9999 反向代理配置 9999是端口
<VirtualHost *:9999>
ServerAdmin xxxx@xx.com 網站管理員郵件地址
ServerName ******** 站點主機名成
ErrorLog "logs/DJBH-error-%Y-%m-%d.log 86400 480" error日志目錄
CustomLog "logs/DJBH-access-%Y-%m-%d.log 86400 480" custom日志目錄
DocumentRoot "D:/xxx/web/ROOT" 靜態文件(即:網頁存儲位置)
DirectoryIndex xx/index.html index.html(即:默認歡迎頁或者首頁) 的相對路徑
<proxy >
Order deny,allow
Allow from all
</proxy>
ErrorDocument 404 /DJBH/404.html 報錯頁面路徑
ErrorDocument 403 /DJBH/403.html 報錯頁面路徑
ErrorDocument 500 /DJBH/500.html 報錯頁面路徑
ProxyPass /xx ajp://172.16.20.221:8009/xx 重點在於ajp 在你的服務器(tomcat之流)的配置(server.xml文件)中查看ajp端口,記住不是http端口
ProxyPassReverse /xx ajp://172.16.20.221:8009/xx
ProxyPass和ProxyPassReverse 反向代理配置 即 :將該主機收到的請求 代理到172.16.20.221:8009 然后反向響應
</VirtualHost>