PDA

View Full Version : Installing Tomcat 5.5.9 for Apache 1 & 2



murali
06-29-2005, 05:10 AM
The following can be used to get jsp pages to be accessed with apache .
Tomcat 5.5.9 has jsp 2 and Servlet 2.4


Installing Tomcat 5.5.9 for Apache 1 & 2 Tested with RHEL3, CentOS 3.5 and CentOS 4.0 For Apache 2


1. vi /etc/profile

export JAVA_HOME='/usr/local/java'
export CATALINA_HOME='/usr/local/tomcat'
export TOMCAT_HOME='/usr/local/tomcat'
source /etc/profile

2. cd /usr/local

Download jdk-1_5_0_04-linux-i586.bin from http://java.sun.com/j2se/1.5.0/download.jsp

chmod 755 jdk-1_5_0_04-linux-i586.bin

./jdk-1_5_0_04-linux-i586.bin

ln -s jdk1.5.0_04 java

/usr/local/java is JAVA_HOME

3. Download jakarta-tomcat-5.5.9.tar.gz from http://archive.apache.org/dist/jakarta/tomcat-5/v5.5.9/bin/jakarta-tomcat-5.5.9.tar.gz

tar zxvf jakarta-tomcat-5.5.9.tar.gz

ln -s jakarta-tomcat-5.5.9 tomcat

/usr/local/tomcat is TOMCAT_HOME and CATALINA_HOME

4. Download jakarta-tomcat-connectors from http://archive.apache.org/dist/jakarta/tomcat-connectors/jk/jakarta-tomcat-connectors-jk-1.2-src-current.tar.gz

tar zxvf jakarta-tomcat-connectors-jk-1.2-src-current.tar.gz

cd /usr/local/jakarta-tomcat-connectors-jk-1.2.6-src/jk/native/
- ./buildconf.sh
- ./configure --with-apxs=/usr/sbin/apxs
- make
- Depending on apache1 or 2
cp apache-1.3/mod_jk.so /etc/httpd/modules/
(or)
cp apache-2.0/mod_jk.so /etc/httpd/modules/


5. cp -p /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.bak

vi /etc/httpd/conf/httpd.conf

After this line :
LoadModule cgi_module modules/mod_cgi.so

Add :
LoadModule jk_module modules/mod_jk.so

Include "/usr/local/jakarta-tomcat-5.5.9/conf/mod_jk.conf"

6. vi /usr/local/jakarta-tomcat-5.5.9/conf/mod_jk.conf

Enter the following lines:

<IfModule !mod_jk.c>
LoadModule jk_module /usr/lib/httpd/modules/mod_jk.so
</IfModule>


JkWorkersFile "/usr/local/jakarta-tomcat-5.5.9/conf/jk/workers.properties"
JkLogFile "/usr/local/jakarta-tomcat-5.5.9/logs/mod_jk.log"

JkMount /*.jsp ajp13
JkMount /servlet/* ajp13
JkMount /servlets/* ajp13
JkMount /*.do ajp13
JkMount /manager/* ajp13

JkLogLevel emerg


7. mkdir /usr/local/jakarta-tomcat-5.5.9/conf/jk
- vi /usr/local/jakarta-tomcat-5.5.9/conf/jk/workers.properties

Enter the following lines :

# Setting Tomcat & Java Home
workers.tomcat_home=/usr/local/tomcat
workers.java_home=/usr/local/java/java
ps=/
worker.list=ajp13
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13

8. Edit /usr/local/jakarta-tomcat-5.5.9/conf/server.xml

Before the last three lines of original server.xml file

</Engine>
</Service>
</Server>

You can add virtual host entries

<Host name="mysite.com" debug="0"
appBase="/usr/local/tomcat/mysite.com" unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Alias>www.mysite.com</Alias>
<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs" prefix="mysite.com"
suffix=".log" timestamp="true"/>
<Context path="" docBase="" debug="0" allowLinking="true"/>
<Listener className="org.apache.catalina.startup.UserConfig"
directoryName="mysite.com"
userClass="org.apache.catalina.startup.PasswdUserDatabase"/>
</Host>

Note : You can use any path instead " /usr/local/tomcat/mysite.com "


9. Execute

/usr/local/tomcat/bin/startup.sh to start tomcat
and restart apache
/etc/init.d/httpd restart

That's it..

Make sure you have configured apache httpd.conf and server.xml for the same path of virtual host...

If you face any error in connector (step 4) try the following method :

Download the Java Connector from CVS and build / install mod_jk
- cvs -d :pserver:anoncvs@cvs.apache.org:/home/cvspublic login password: anoncvs (When prompted for a password, just hit ENTER)
- cvs -d :pserver:anoncvs@cvs.apache.org:/home/cvspublic checkout jakarta-tomcat-connectors
- mv jakarta-tomcat-connectors /usr/local/java/
- cd /usr/local/java/jakarta-tomcat-connectors/jk/native/
- ./buildconf.sh

- ./configure --with-apxs=/usr/sbin/apxs
- make
- cp apache-1.3/mod_jk.so /etc/httpd/modules/
(or)
- cp apache-2.0/mod_jk.so /etc/httpd/modules/

nobaloney
07-01-2005, 05:06 PM
murali,

Would you please be so kind as to create a paragraph at the top of this How-To explaining just what it is for?

Thanks.

Jeff

murali
07-02-2005, 03:18 AM
jlasman

Is that ok...?

resolveit
07-02-2005, 02:48 PM
Ok, tried this but the following issues...

From step 4 on you seem to have left out a lot of untarring and other commands.

I followed through and almost got everything working but when I restart Apache I get



Syntax error on line 6 of /usr/local/tomcat/conf/mod_jk.conf:
Invalid command 'JkWorkersFile', perhaps mis-spelled or defined by a module not included in the server configuration


What do you mean by...



Make sure you have configured apache httpd.conf and server.xml for the same path of virtual host...


Should tomcat not be included in the startup routines of the server so it restarts when the server is rebooted?

Please let me know...

Regards,
Onno

nobaloney
07-03-2005, 05:17 PM
Originally posted by murali
Is that ok...?

I guess it's the tile that's confusing me.

What do you mean by "Apache 1/2 Tomcat 5.5.9"?

Do you mean "installing Tomcat 5.5.9 for Apache 1 & 2"?

If so, can we just call it that?

:)

Please respond to Onno's post; it's important that our How-Tos work :) :) .

Jeff

murali
07-03-2005, 09:43 PM
Yes.. It is "Installing Tomcat 5.5.9 for Apache 1 & 2"

I am altering Now...

Syntax error on line 6 of /usr/local/tomcat/conf/mod_jk.conf:
Invalid command 'JkWorkersFile', perhaps mis-spelled or defined by a module not included in the server configuration

The Reason for the above error might be the following ...

verify the file /usr/local/tomcat/conf/mod_jk.conf for the following . It should be in 2 lines and not in 4 lines.

JkWorkersFile "/usr/local/jakarta-tomcat-5.5.9/conf/jk/workers.properties"
JkLogFile "/usr/local/jakarta-tomcat-5.5.9/logs/mod_jk.log"


Please check and restart apache ...

The following is the error

Starting httpd: Syntax error on line 5 of /usr/local/jakarta-tomcat-5.5.9/conf/mod_jk.conf:
JkWorkersFile takes one argument, the name of a worker file for the Jakarta servlet containers

with the following in /usr/local/jakarta-tomcat-5.5.9/conf/mod_jk.conf

JkWorkersFile
"/usr/local/jakarta-tomcat-5.5.9/conf/jk/workers.properties"
JkLogFile
"/usr/local/jakarta-tomcat-5.5.9/logs/mod_jk.log"



" Make sure you have configured apache httpd.conf and server.xml for the same path of virtual host... "

I mean the DocumentRoot ...

"Should tomcat not be included in the startup routines of the server so it restarts when the server is rebooted? "

NP

lusid
07-26-2005, 08:25 AM
I tried using the other Howto on the forums for installing J2SE 1.4.2 and Tomcat 4, but tried replacing with JDK 5 and Tomcat 5 with no success... then, after reading your howto, and adjusting things as needed, everything worked swell. So thanks!

Only question left is... what would cause /manager not to work? ;)

Thanks,
Marc

lusid
07-26-2005, 08:41 AM
Nevermind, seems to be fine as-is... just have to connect to:

http://[ip address]/manager/

or for the actual interface:

http://[ip address]/manager/html

If you want to add it to each individual host, just add the following <Context> after the other <Context> line listed in each <Host> tag in the server.xml file.

<Context path="/manager" docBase="/usr/local/jakarta-tomcat-5.5.9/server/webapps/manager" debug="0" privileged="true" />

Then restart tomcat.

Good stuff.

kunal
11-16-2005, 06:01 PM
these instructions worked like a charm!!


I have been trying to get this to work for a couple of days now, and then saw these instructions.. deleted everything i had, and decided to start from scratch... worked like a charm!

:)


kunal

SeLLeRoNe
12-05-2005, 03:07 PM
someone tryed it on freebsd5.4? tnx

hehachris
12-23-2005, 08:11 AM
is there any way to control which package can use and which package cannot use?

dfriedlander
02-15-2006, 11:11 AM
Went through your excellent notes with some revisions for Ubuntu's distribution. Most important, it's necessary to install the apache-dev package so apxs is there.

Everything seems to come up fine, but is there a test I can run to see something happen before I tackle installing a servlet?

asmar
02-27-2006, 03:09 PM
I am also getting the same error:

directadmin1:/tmp# /etc/init.d/httpd start
Starting httpd: Syntax error on line 5 of /usr/local/apache-tomcat-5.5.15/conf/mod_jk.conf:
Invalid command 'JkWorkersFile', perhaps mis-spelled or defined by a module not included in the server configuration


Any ideas how to fix this?

Thanks

asmar
02-28-2006, 11:58 PM
ops, just found it. Please ignore my post.

Thanks

SupermanInNY
05-20-2006, 06:52 PM
I know this is an old bump,. but I tried to follow the instructions and sorrry,. I hit a wall on the few first d/l steps.


http://java.sun.com/j2se/1.5.0/download.jsp


2. cd /usr/local

Download jdk-1_5_0_04-linux-i586.bin from http://java.sun.com/j2se/1.5.0/download.jsp

I can't seem to find that bin file.

Perhaps the page was modified,. perhaps the version was changed,. either way there are many options on that page,. none that I'm certain are the correct ones.

Can you point me in the direction of the current d/l version that I would need?

Thanks,

-Alon.

browncow
07-15-2006, 02:56 PM
I'm running Centos 4.3 and grabbed the latest jre from Sun.
The latest Tomcat from Apache.
The latest connector from Apache.
Everything seems to be working, except that I must type
http://domainname:8080/test.jsp

I cannot type

http://domainname/test.jsp

Does this mean my mod_jk connector isn't working?
How do I debug?
What logs do I look at?
What should I look at to confirm is configged properly?

Thanks for your efforts!
Any help or suggestions would be appreciated!

Thanks.
Hao.

SeLLeRoNe
07-26-2006, 05:31 AM
Can be used for FreeBSD?

Thanks for reply

SuperHost3000
04-26-2007, 07:19 AM
Works this how-to on a Centos 4.4 box?

asmar
04-26-2007, 09:59 AM
This is a generic howto, not rpm/distribution specific so should work without problems.
The ideal scenario is to test it first on a vmware instance to be familiar with Tomcat and then install it on the production server.

Cheers

Kod
04-28-2007, 03:47 PM
Hi there,

I'm getting the following errors when starting apache :

Syntax error on line 6 of /usr/local/tomcat/conf/mod_jk.conf:
Invalid command 'JkWorkersFile', perhaps mis-spelled or defined by a module not included in the server configuration

JkWorkersFile and JkLogFile are on 2 lines.

Any help ?

Thanks

asmar
04-29-2007, 04:35 AM
Hi Kod,

Post your Apache's version along with the mod_jk
There are a few changes from version to version.
Check first the error at google, it is usually related with the version that you are using.

If you cannot find any way to solve it post here your config files.

Cheers

Kod
04-30-2007, 02:09 AM
Hi

I'm running Apache/1.3.37 along with mod_jk 1.2.14

and here's the mod_jk.conf


<IfModule !mod_jk.c>
LoadModule jk_module /usr/lib/httpd/modules/mod_jk.so
</IfModule>
JkWorkersFile "/usr/local/jakarta-tomcat-5.5.9/conf/jk/workers.properties"
JkLogFile "/usr/local/jakarta-tomcat-5.5.9/logs/mod_jk.log"
JkMount /*.jsp ajp13
JkMount /servlet/* ajp13
JkMount /servlets/* ajp13
JkMount /*.do ajp13
JkMount /manager/* ajp13
JkLogLevel emerg

I checked the error with google, nothing helpful there.

Thanks

deltaforce
05-13-2007, 12:35 AM
If we want to run servlets then simply put the class files in the path define in server.xml /usr/local/tomcat/mysite.com

magixman
11-20-2007, 04:58 PM
Followed the instructions using JDK 5.0.14 Tomcat 5.5.25.

The only issue I ran into was that I was getting this error in the apache error log (apache 1.3):

Cannot remove module mod_jk.c: not found in module list

After searching the web I found an article that mentioned that you also need to do the addmodule AddModule mod_jk.c at the end of the AddModules and the include of the mod_jk.conf after that. Doing that did the trick for me.

The article is kind of old but provided some other useful info for newbies to Tomcat:

http://www.yolinux.com/TUTORIALS/LinuxTutorialTomcat.html

jan267
05-03-2008, 10:00 AM
Hello!
Thanks a lot for your tutorial... i have followed every step, and everything work correctly. Except for one thing: every page .do or .jsp returns an Internal Server Error 500.
Why? :confused: