| Win2K下Apache2+TomCat5.0整合解决方案 |
| |
发布者: 发布时间:2006-07-10 |
|
|
|
Win2K下Apache2.0+TomCat5.0解决方案 操作系统:windows 2000 professional 中文版+sp4 java 环境:j2sdk1.4.2_01 JAVA_HOME= C:\j2sdk1.4.2_01 apache 2.0.48 for win32:apache_2.0.48-win32-x86-no_ssl.msi下载地址 http://archive.apache.org/dist/httpd/ tomcat 5.0.16 for win32:jakarta-tomcat-5.0.16.exe下载地址 http://jakarta.apache.org/site/binindex.cgi jk2 模块 for win32: mod_jk2-2.0.43.dll 下载地址 http://apache.scarlet.be/jakarta/tomcat-connectors/jk2/binaries/win32/ 以上软件的下载网址:http://www.apache.org 1. 安装并测试Apache和TomCat5.0; 注意事项: Apache默认端口为80,与IIS冲突,更改端口或关闭IIS, TomCat安装完后配置环境变量。 2. 开始整合; 首先,将文件mod_jk2.so 复制到Apache 的模块目录(%Apache%\Apache2\modules)中。 备份Tomcat 和Apache 的缺省配置文件,以防不测。 其次,编辑配置文件。具体的配置文件有四个, 它们分别是:httpd.conf、jk2.properties、server.xml、workers2.properties。
a、 修改ApacheRoot\Apache2\conf\httpd.conf 文件 1>修改web 主目录,即将 DocumentRoot "D:/websrv/Apache2/htdocs" 改为自己的web主目录 eg: DocumentRoot "D:/websrv/myweb" 2>修改web 主目录对应的目录,即将 <Directory "D:/websrv/Apache2/htdocs">改为 eg: <Directory "D:/websrv/myweb" > 此目录块要与DocumentRoot的路径对应,块中的语法是对此块对应Web主目录的操作权限设置。 3>修改目录缺省的web 文件,即将 DirectoryIndex index.html index.html.var 改为 eg: DirectoryIndex index.html index.html.var index.jsp 语法说明:当向Apache 发出请求时容器将顺次去找index.html,如果没有,将接着找index.htm,最后找index.jsp。 4>修改cgi-bin 所在目录,即将 ScriptAlias /cgi-bin/ "D:/websrv/Apache2/cgi-bin/"改为 ScriptAlias /cgi-bin/ "D:/websrv/myweb/cgi-bin/" <Directory "D:/websrv/Apache2/cgi-bin"> 改为 <Directory "D:/websrv/myweb/cgi-bin"> 如果程序中需要用到cgi时修改以上两处。 5>添加指定的虚拟目录(别名),及其对应目录的属性 #这是测试用的文件夹,能执行jsp 文件。 Alias /jj/ "D:/websrv/myweb/jj/" <Directory "D:/websrv/myweb/jj" > AllowOverride None Options IncludesNoExec AddOutputFilter Includes html AddHandler type-map var Order allow,deny Allow from all </Directory>
Alias /chengxin/ "D:/websrv/myweb/chengxin/" <Directory "D:/websrv/myweb/chengxin" > AllowOverride None Options IncludesNoExec AddOutputFilter Includes html AddHandler type-map var Order allow,deny Allow from all </Directory> #在web主目录myweb中添加了两个测试应用程序jj和chengxin 语法说明: Alias /web程序别名/ "程序根目录/" ##别忘啦最后有“/” <Directory "程序根目录" > AllowOverride None Options IncludesNoExec AddOutputFilter Includes html 对此程序的具体操作权限设置 AddHandler type-map var Order allow,deny Allow from all </Directory> 注意: 程序根目录必须和%Tomcat5%\conf\server.xml中配置的虚拟目录相吻合。 6>修改缺省的字符集,使之支持中文,即将 AddDefaultCharset ISO-8859-1 改为 AddDefaultCharset GB2312 7>在文件最后添加如下内容,以加载jk2 模块 <IfModule !mod_jk2.c> LoadModule jk2_module modules/mod_jk2.so </IfModule>
b、 修改Tomcat5Root\conf\jk2.properties 文件 在文件最后添加如下内容,打开shm 文件设置 #Shared memory directive shm.file=ApacheRoot/Apache2/logs/jk2.shm 可以在ApacheRoot/Apache2/logs/下新建jk2.shm文件 c、 修改Tomcat5Root\conf\server.xml 文件 在apache 中对应指定的虚拟目录,server.xml 中也应指定,所以在 <!-- Tomcat Root Context --> <!-- <Context path="" docBase="ROOT" debug="0"> --> 的下面添加 <Context path="/jj" docBase="d:\websrv\myweb\jj" debug="0" reloadable="true" crossContext="true"></Context> <Context path="/chengxin" docBase="d:\websrv\myweb\chengxin" debug="0" reloadable="true" crossContext="true"></Context>
d、 修改ApacheRoot\Apache2\conf\workers2.properties 文件 注意:如果此文件不存在,则在目录ApacheRoot \Apache2\conf 下新建一个。 添加如下内容 #*************************************************************************** # only at beginnin. In production uncomment it out 必须在文件开头定义 [logger.apache2] level=DEBUG #define the shared memory file 定义shm 文件 [shm] file=ApacheRoot /Apache2/logs/jk2.shm #指向Apache文件下的logs/jk2.shm文件 size=1048576 # Define the communication channel 定义信道 [channel.socket:localhost :8009] tomcatId=localhost :8009 # define the worker [ajp13:localhost:8009] channel=channel.socket:localhost:8009 #jk2 的状况,可通过http://localhost/status 查看 [status:] info=Status worker, displays runtime information channel=channel.socket:localhost:8009 # Uri mapping Uri 映射 #[uri:/path/*]会把http://域名/path/里的所有请求发给tomcat。 #而[uri:/path/*.jsp]会把http://域名/path 里的jsp 文件请求发给tomcat 处理。 #此path 可以是apache 的虚拟目录,也可以是tomcat 的虚拟目录, #还可以是tomcat 的物理目录,这儿是配置jk2 的关键,试试就知道了。 [uri:/status/*] worker=status:localhost:8009 group=status: #[uri:/*] ###表示web主目录下的所有请求都给TomCat处理 [uri:/jj/*.jsp] ###表示web主目录下的jj程序中所有jsp文件请求都给TomCat处理 [uri:/chengxin/*] ###表示web主目录下的changxin程序中所有请求都给TomCat处理 #[uri:/jsp/*.jsp] worker=ajp13:localhost:8009 info=Map the whole webapp 注意:此文件中的8009端口设置必须与TomCatRoot\conf\server.xml文件中 <Connector port="8009" enableLookups="false" redirectPort="8443" debug="0" protocol="AJP/1.3" /> 对应。 到此已基本配置完成。
如果要通过配置虚拟主机的方法来访问还要进行以下配置: 以下配置的是一个IP对应多个域名的方法。 1> 在apacheRoot\apache2\conf\httpd.conf修改 Listen 80 #监听端口为80 #NameVirtualHost *:80 为 NameVirtualHost 192.168.1.208:80 ##################################Ip影射到程序主目 <VirtualHost 192.168.1.208:80> #管理员Email ServerAdmin webmaster@dummy-host.example.com #jj web程序目录 DocumentRoot d:/websrv/myweb/jj #域名 ServerName ccjg.test.com #日志 ErrorLog logs/dummy-host.example.com-error_log CustomLog logs/dummy-host.example.com-access_log common #多个域名对应一个程序是可以在此添加 ServerAlias ccjg.test.gov.cn #注意: #每在ServerName或ServerAlias添加一个域名时相应的就应该在 #TomcatRoot\conf\server.xml文件中添加相应的<Host>块标记与之对应 #如果要在本机测试则在C:\WINNT\system32\drivers\etc\hosts须添加相应 #的IP对应于你的所设置域名,域名解析时用到 #eg: 192.168.1.208 ccjg.test.gov.cn # 192.168.1.208 ccjg.test.com </VirtualHost>
<VirtualHost 192.168.1.208:80> ServerAdmin webmaster@dummy-host.example.com #chengxin web程序目录 DocumentRoot d:/websrv/myweb/chengxin ServerName chengxin.test.com ErrorLog logs/dummy-host.example.com-error_log CustomLog logs/dummy-host.example.com-access_log common ServerAlias ccjg.test.gov.cn </VirtualHost> 以上是一个IP对应两个web程序。 2> 在TomCatRoot\conf\server.xml中添加对应的<Host>块 <Host name="ccjg.test.com" debug="0" appBase="d:/websrv/jj" unpackWARs="true" autoDeploy="true"> <Context path="" docBase="" debug="0"/> <logger className="org.apache.catalina.logger.FileLogger" directory="logs" prefix="cust1_log." suffix=".txt" timestamp="true"/> </Host> <Host name="ccjg.test.gov.cn" debug="0" appBase="d:/websrv/jj" unpackWARs="true" autoDeploy="true"> <Context path="" docBase="" debug="0"/> <logger className="org.apache.catalina.logger.FileLogger" directory="logs" prefix="cust1_log." suffix=".txt" timestamp="true"/> </Host> 到此OK
|
| (转载文章请保留出处:北天JAVA技术网(www.java114.com)) |
| |
| 更多精彩文章: |
| 彻底解决Tomcat 5.0.19的中文乱码问题 |
| Tomcat5+Mssql server 2000数据库连接池配置之旅 |
| 配置Tomcat 4.1.29的连接池 |
| Tomcat 4.x的配置与管理 |
| 根本解决Tomcat里面的中文问题 |
| WebLogic 6.1使用技巧 |
| |
| 最近评论: |
|
|
| Chadwick |
| 0e68a8f0f9700fdf461aee50842179d7 http://trucco-burnout-legend-psp.enadzh.biz/ http://macchia-giarre.kajgdw.biz/ http://grande-dittatore-chaplin-anno.enadzh.biz/ http://ronchi-della-rocca.iuatju.biz/ http://vendo-cavallo.ygvhik.biz/ http://bimbo-chicco.zibtye.biz/ http://passano-natale-norvegia.tzlnou.biz/ http://atto-malefici.kajgdw.biz/ http://rapporto-ice.enadzh.biz/ http://atti-civili.iuatju.biz/ 69fae163d26a9b1682339a4eb6fc4ad9 |
|
|
| Marcelo |
| 7115b0d9aceb056c6ee974221917b4db http://macchina-agricole-bcs.cqhnnx.org/ http://istruzione-it-esami-di-maturita.mnkcbe.org/ http://zeppa-scarpa.jnbwct.org/ http://creare-un-cluster.gbdrme.org/ http://autogru-marchetti.mnkcbe.org/ http://logo-gruppo-musicale.pvaeyo.org/ http://negozio-aperto-domenica-dicembre.pvaeyo.org/ http://paesi-terzo-mondo.jnbwct.org/ http://insana-cumshot.pvaeyo.org/ http://cattedrale-barletta.cqhnnx.org/ eb89aa2351bfb8dd061b0dc25061dcdb |
|
|
| Jamison |
| 4a4a40b370f67673c48e5cc92992e38a PrinceHelsley RoxasHouston ShoaffHassan VillacisBill ArakiElian WilletteTrever IsraelSim BlaineKlick MoorheadJered IsraelSim 1bb5907b91a875f331998f8e4f2b0572 |
|
|
| Unknown |
| 55a39ecf25b0e5dee57d0f6ccac8a23d canzone fare amore gioco nokia 7250i cambiare scuola storia boole come allungare il cazzo centro cefalee genova azienda ospedaliera san paolo immagine tutti it capodanno gay roma cogne trascrizioni intercettazioni telefonica b8fb7d84153cc5c69600cbe1497734b2 |
|
|
| Donald |
| 8c1a21d0894e4fccba618b5d30821705 http://alice-meraviglia-paese.aezqpa.com/ http://bibione-turismo.miwcjz.com/ http://istituto-nautico-camogli.qeshtw.in/ http://annuncio-coppia-fanno-sesso-clistere.kmyeyh.com/ http://anteprime-video-porno-free.jvzulp.in/ http://fodere-divano.vbglda.com/ http://normativa-legge-depositi-magazzino-pneumatico.aoknmm.in/ http://prove-strada-moto.jnesky.in/ http://bordo-sfondo-natalizio.kmyeyh.com/ http://webcam-marzano-appio.iznvge.in/ b8a12f78e2ab8d9c8e5e94f78e975725 |
|
|
| Aubrey |
| http://74cbef9a9d018198c99c042f2b51d432-t.xkktxb.org 74cbef9a9d018198c99c042f2b51d432 [url]http://74cbef9a9d018198c99c042f2b51d432-b1.xkktxb.org[/url] [url=http://74cbef9a9d018198c99c042f2b51d432-b2.xkktxb.org]74cbef9a9d018198c99c042f2b51d432[/url] [u]http://74cbef9a9d018198c99c042f2b51d432-b3.xkktxb.org[/u] 8d1f2bfe3cbc5359328d95464cab8b7c |
|
|
| Judah |
| cb356a2432f24216bbab33977ee917b1 trucco dbz budokai tenkaichi 2 sull isola di ischia telefoni cellulari and danni cartina topografica di brescia brasile argentina idraulico varese modifica motori gente motori milano san fermo prodi berlusconi faccia 8ea4fcdde1a965ef95e68187f350c6f6 |
|
|
| Arturo |
| http://7b6a5c7cd48b76ebd23394217e0cbdf7-t.lwgmrw.org 7b6a5c7cd48b76ebd23394217e0cbdf7 [url]http://7b6a5c7cd48b76ebd23394217e0cbdf7-b1.lwgmrw.org[/url] [url=http://7b6a5c7cd48b76ebd23394217e0cbdf7-b2.lwgmrw.org]7b6a5c7cd48b76ebd23394217e0cbdf7[/url] [u]http://7b6a5c7cd48b76ebd23394217e0cbdf7-b3.lwgmrw.org[/u] 7323937625928ec2c2b389a5c949efe8 |
|
|
| |
| 免责声明:该文章由网友发表,如果对您造成侵权,请联系站长。 |