apache2.2 tomcat6.0實(shí)戰(zhàn)
以下紅色皆為測(cè)試參數(shù),可自行定義:一,系統(tǒng)。 .............................................................................
以下紅色皆為測(cè)試參數(shù),可自行定義:
一,系統(tǒng)。 ........................................................................................................ 1
二,安裝軟件..................................................................................................... 1
三, 測(cè)試 . ......................................................................................................... 1
四,配置apache ................................................................................................. 2
五,配置tomcat ................................................................................................. 4
六,整合實(shí)戰(zhàn)。 ................................................................................................. 4
意事項(xiàng)及出現(xiàn)的問(wèn)題:....................................................................................... 4
實(shí)戰(zhàn)設(shè)置: ........................................................................................................ 5
一,系統(tǒng)。
Window XP(2003)
二,安裝軟件(安裝路徑不要有空格) 。
1,appserv-win32-2.5.10.exe
安裝目錄:C:AppServ 端口80
安裝過(guò)程中需要指定服務(wù)器所在的DNS 域名、服務(wù)器DNS 名稱、管理員郵箱,以及服務(wù)器啟動(dòng)參數(shù)。沒有域名可以指定DNS 域名和服務(wù)器DNS 名稱為localhost 。實(shí)際工作中,DNS 域名為所購(gòu)域名的后半部分,服務(wù)器DNS 名稱即為所購(gòu)域名。如果服務(wù)器沒有提供郵件服務(wù),管理員郵箱可以任意指定。
,2,JDK6
安裝目錄:C:Java 配置好相應(yīng)的環(huán)境變量(JA V A_HOME,PA TH ,CLASS_PATH ) ,3,Tomcat6
安裝目錄:C:Tomcat 6.0 端口為81
安裝中需要指定Tomcat 使用的端口號(hào)、服務(wù)器管理員登錄用戶名和密碼。前面的可以按照默認(rèn)的來(lái),用戶名和密碼要牢記。
三, 測(cè)試。
1,驗(yàn)證JDK 安裝狀態(tài)
打開cmd 命令窗口,輸入java
2,開啟apache2.2服務(wù) http://127.0.0.1/
3,開啟tomcat 服務(wù)
,四,配置apache (整個(gè)過(guò)程其實(shí)就是讓apache 的httpd.conf 文件調(diào)用mod_jk.conf,mod_jk.conf調(diào)用workers.properties ) 。
1,打開C:AppServApache2.2confhttpd.conf文件
在最后的LoadModule 行(安ctrl f查找LoadModule )下面加上
LoadModule jk_module modules/mod_jk.so
2,在配置文件的最下面加上
Include conf/mod_jk.conf
3,在C:AppServApache2.2modules文件夾下加上
mod_jk-apache-2.2.4.so (要和apache 版本相同,或則盡量選擇版本接近,這點(diǎn)很重要) 文件 并改名為mod_jk.so
4,在C:AppServApache2.2conf文件夾下加上
mod_jk.conf
(主要定義mod_jk模塊的位置以及mod_jk模塊的連接日志設(shè)置,還有定義worker.properties 文件的位置。)
文件 文件內(nèi)容如下:
JkWorkersFile C:AppServApache2.2confworkers.properties
JkLogFile C:AppServApache2.2logs/mod_jk.log
JkLogLevel info
JkLogStampFormat "[a b d H:M:S Y]"
JkOptions ForwardKeySize ForwardURICompat -ForwardDirectories
JkRequestLogFormat "w V T"
JkMount /*.PictureCheckCode s1
JkMount /servlet/* s1
JkMount /*.jsp s1
JkMount /*.action s1
5,在C:AppServApache2.2conf文件夾下加上
workers.properties
(定義worker 的參數(shù),主要是連接tomcat 主機(jī)的地址和端口信息。如果Tomcat 與apache 不在同一臺(tái)機(jī)器上,或者需要做多臺(tái)機(jī)器上tomcat 的負(fù)載均衡只需要更改workers.properties 文件中的相應(yīng)定義即可。)
文件 文件內(nèi)容如下:
worker.list= s1
worker.s1.port=8009
worker.s1.host=localhost
,worker.s1.type=ajp13
worker.DLOG4J.type=lb
worker.retries=3
worker.DLOG4J.balanced_workers=s1
worker.DLOG4J.sticky_session=1
worker.status.type=status
6,修改Apache 的文檔主目錄。把DocumentRoot 和
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "E:wwwroot"
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews # # Note that "MultiViews" must be named *explicitly* --- "Options All" # doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks MultiViews ExecCGI
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
,7, 修改C:AppServApache2.2confhttpd.conf文件的配置:
DirectoryIndex index.html index.jsp index.php index.htm
五,配置tomcat 。
1,修改Tomcat 的文檔主目錄。打開C:Tomcat 6.0conf server.xml文件 把 unpackW ARs="true" autoDeploy="true" xmlV alidation="false" xmlNamespaceAware="false"> 六,整合實(shí)戰(zhàn)。 1,在 E:wwwroot下放入項(xiàng)目 2,重新啟動(dòng)apache2.2和tomcat 服務(wù)器 3,測(cè)試項(xiàng)目 意事項(xiàng)及出現(xiàn)的問(wèn)題: 端口號(hào)被占用 實(shí)戰(zhàn)設(shè)置: 參考:http://lamp.linux.gov.cn/Apache/ApacheMenu/index.html 1,重定向:httpd.conf 配置: ##########重定向######################################## # # 第二種方法: # RedirectMatch ^/$ http://127.0.0.1/finance/Main.action # ##########重定向######################################## RewriteEngine on RewriteRule ^/$ /finance/Main.action [R] 2,限制文件訪問(wèn):httpd.conf 配置: #########禁止訪問(wèn)finance 項(xiàng)目下的WEB-ING 文件夾下的文件############## Order allow,deny Deny from all 3,一般情況下,不應(yīng)該使用.htaccess 文件 禁用自動(dòng)掃描.htaccess 文件,httpd.conf 配置: # # Possible values for the Options directive are "None", "All", # or any combination of: # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews # # Note that "MultiViews" must be named *explicitly* --- "Options All" # doesn't give it to you. # # The Options directive is both complicated and important. Please see # http://httpd.apache.org/docs/2.2/mod/core.html#options # for more information. # Options Indexes FollowSymLinks MultiViews ExecCGI # # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride None # # Controls who can get stuff from this server. # Order allow,deny Allow from all 4,apache 網(wǎng)頁(yè)錯(cuò)誤控制跳轉(zhuǎn),httpd.conf 配置: # # Customizable error responses come in three flavors: # 1) plain text 2) local redirects 3) external redirects # # Some examples: #ErrorDocument 500 "The server made a boo boo." ErrorDocument 401 /401.html ErrorDocument 404 /404.html ErrorDocument 403 /403.html ErrorDocument 503 /503.html #ErrorDocument 404 "/cgi-bin/missing_handler.pl" #ErrorDocument 402 5,tomcat 網(wǎng)頁(yè)錯(cuò)誤控制跳轉(zhuǎn),C:tomcat6confweb.xml配置: 優(yōu)化參考: 1,TOMCA T apache 2000萬(wàn)訪問(wèn)量的實(shí)現(xiàn): http://www.360doc.com/content/09/1010/15/186523_7068797.shtml 2,修改tomcat 內(nèi)存大?。?http://edu.codepub.com/2010/0327/21418.php 3,tomcat 優(yōu)化配置: 4,apache tomcat 我是初學(xué)者!很需要經(jīng)驗(yàn)指導(dǎo)和錯(cuò)誤糾正等等學(xué)習(xí),有的忘告知,大家一起學(xué)習(xí)進(jìn)步?。?! 郵箱:shangchenbs@qq.com