Tomcat

From WeWeWeb Wiki
Jump to navigationJump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Apache 2 + tomcat 5 in Fedora

Steps (only steps, fetches online resources if you would like to understand the rational behind)

1. install the following packages if you missed

-- httpd
-- httpd-devel
-- tomcat5

1.1. Install tomcat manually

1.1.1 Go to http://tomcat.apache.org/ and download the Linux Tomcat, current version is apache-tomcat-6.0.26.tar.gz

1.1.2. Extract it under /opt (say)

1.1.3. Create a symbolic link

 ln -s /opt/apache-tomcat-6.0.26 /opt/tomcat

1.1.4. Create a system service file tomcat and put it under /etc/rc.d/init.d. Remember a add "x" attribute to the file with the command:

 chmod +x tomcat

1.1.5. Add tomcat user and group

 groupadd -g 232 tomcat
 useradd -g tomcat -d /opt/tomcat -u 232 tomcat
 

1.1.6. Change the tomcat folder to tomcat:tomcat

 chown -R tomcat:tomcat /opt/tomcat
 chown -R tomcat:tomcat /opt/apache-tomcat-6.0.26

1.1.7. In the file catalina.sh in the bin folder of tomcat, add jdk location

 JAVA_HOME=/opt/java
 JRE_HOME=/opt/java

2. Prepare Tomcat Connectors (Starting from Apache 2.2, mod_proxy_ajp will be used to replace mod_jk)

2.1. Build from source

2.1.1. download Tomcat Connectors

-- JK 1.2 http://tomcat.apache.org/download-connectors.cgi

2.1.2. extract the download file and go to the directory jakarta-tomcat-connectors-1.2.15-src/jk/native have a look on BUILDING if you want

2.1.3. Build

-- go to the directory

jakarta-tomcat-connectors-1.2.15-src/jk/native

-- run the following command

./configure --with-apxs=/usr/sbin/apxs

if there is an error, check with config.log (for me, i miss a cpp complier, and i choose to install gcc-c++)

-- run make

make


2.2. Download the prebuild module

Go to the url http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/

download the current vesion: mod_jk-1.2.28-httpd-2.2.X.so

3. copy the module

cp ./apache-2.0/mod_jk.so /usr/lib/httpd/modules/

4. JKWorkersFile

-- go to directory

jakarta-tomcat-connectors-1.2.15-src/jk/conf

-- edit the workers.properties

i. find the tomcat home and java home directory variable

workers.tomcat_home=/var/tomcat3
...
workers.java_home=/opt/IBMJava2-13

and change the path point to the corresponding home directory in your system you may reference to /etc/tomcat5/tomcat5.conf

ii. change the java lib for the worker find the following comments

#
# The JVM that we are about to use
#

!!! and change the setting according to your java version and platform

-- run the following command cp workers.properties /etc/httpd/conf/

5. edit httpd.conf -- open /etc/httpd/conf/httpd.conf in your favorable editor

-- find the section LoadModule and add the following line on the last LoadModule declaration

# for integrate tomcat 5
LoadModule jk_module modules/mod_jk.so

-- find the section IfModule and add the following at last

# for integrate tomcat 5
<IfModule mod_jk.c>
    JkWorkersFile /etc/httpd/conf/workers.properties
    JkLogFile /var/log/httpd/mod_jk.log
    JkLogLevel info
    JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
    JkMount /* ajp13
</IfModule>

6. test configuration is error-free apachectl -t

7. restart httpd and tomcat5

8. test your server


Goto Linux