Monday, June 15, 2009

Multiple Instance of Tomcat

Fedora10

1. tomcat5 (5)

2. Apache (2.2.10)

3. java (5)

Default rpm configuration

3.Tomcat (6) binary installed in /opt/tomcat

Tomcat uses port 8080 as default here we have to change port of any one server to some other port

Default

1 .rpm tomcat5 works in default port

2. /opt/tomcat - Here go to /opt/tomcat/conf open vim server.xml
Here ajp connecting port must be
enableLookups="false" redirectPort="8443" protocol="AJP/1.3">
And connecting port must be

maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" />

Test both tomcat using netstat -lptn and using browser

http://localhost:8080
http://localhost:10111

Using netstat -lptn

EN 1323/rpcbind
tcp 0 0 :::8080 :::* LISTEN 10589/java
tcp 0 0 :::80 :::* LISTEN 10093/httpd
tcp 0 0 :::22 :::* LISTEN 24161/sshd
tcp 0 0 :::10111

When this is finished we have to connect tomcat and apache and we use mod_jk modules for that

Download jk_module and place it in /etc/httpd/modules

Next step is making configuration for mod_jk

Make a file vim /etc/httpd/conf.d/mod_jk.conf

LoadModule jk_module modules/mod_jk.so
JkWorkersFile /etc/httpd/conf/workers.properties
JkShmFile /var/log/httpd/mod_jk.shm
JkLogFile /var/log/httpd/mod_jk.log
JkLogLevel info

Here we are mentioning workers.properties file and mod_jk log file

Next we have to create a workers.properties file

vim /etc/httpd/conf/workers.properties
workers.tomcat_home=/usr/share/tomcat5
workers.java_home=/usr/lib/jvm/java
worker.list=jkworker
worker.jkworker.port=8009
worker.jkworker.host=localhost
worker.jkworker.type=ajp13
workers.tomcat_home=/opt/tomcat
workers.java_home=/usr/lib/jvm/java
worker.list=jkworker
worker.jkworker.port=8010
worker.jkworker.host=localhost
worker.jkworker.type=ajp13

Here we are mentioning which tomcat we are using as well as which port no they are using

Last step is to mention which file should be loaded

Here we are using jsp-examples which is there in tomcat directory

That we have to mention in vim /etc/httpd/conf/httpd.conf

JkMount /jsp-examples/* jkworker

restart
/etc/init.d/httpd start
/etc/init.d/tomcat5 start
/opt/tomcat/bin/./startup.sh

No comments:

curl and cacert

curl -v --cacert cacert.pem https://www.example/cgi-bin/f ile.xgi -I -X POST