Go Back   cPanel Forums > cPanel® and WHM® (for Linux® and FreeBSD® Servers) > cPanel and WHM Discussions

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-05-2003, 04:48 PM
Planet_Master's Avatar
Registered User
 
Join Date: Apr 2002
Location: New Yorker
Posts: 260
Planet_Master
Exclamation Step by step install for Tomcat 4.1.12 and JDBC drivers

Sorry about the title its not 4.1.29 its 4.1.12. Will try 4.1.29 and post results of that install as well soon,. I have installed the latest stable release Tomcat 4.1.12 (Oct 31) and the JDBC drivers and have had excellent success on cpanel run servers.

I use the latest version (not 4.0.3 as used here) because it does fix many bugs, is more efficient and doesnt require the old restarts when new scripts are added. It is good to go out of the box and really adds to your servers value if you get both options to run well.

Heres a guide to installing

First, if you already have another version of Tomcat on your server, clean it out. Delete these files:
in /usr/local
jakarta
in /
jsp-install-4 (or whatever version you have)

Then edit httpd.conf and remove all instances of

<IfModule mod_jk.c>
JkMount /*.jsp ajp13
JkMount /servlet/* ajp13
JkMount /servlets/* ajp13
</IfModule>
</VirtualHost>

Make sure you write down the accounts that have JSP installed so you can reinstall

Also take out the following line:
AddModule mod_jk.c
(In some cases depending on your boxes configuration this line will make it work without adding mod_jk2.c ::Go figure:-)

You can leave:
AddType text/html .jsp
index.jsp in the DirIndex


now to install the new version SSH as root

wget http://layer1.cpanel.net/jsp-install-4.x.tar.gz
tar xfzv jsp-install-4.x.tar.gz
cd jsp-install-4
./install.sh

That will install Tomcat

NOTE: You may get this error right off the bat;
error: failed dependencies:
compat-libstdc++ = 6.2-2.9.0.16 is needed by compat-egcs-c++-6.2-1.1.2.16

Not to worry, after install go to WHM and reinstall the compat-libstdc++ and check ignore dependencies and forced install. That will update that.


Now open httpd.conf again and add the following so it looks like the following (You may already have some of these from install):

LoadModule jk2_module libexec/mod_jk2.so


AddModule mod_jk2.c
Include "/usr/local/jakarta/jakarta-tomcat-4.1.12-src/build/conf/auto/mod_jk.conf"

AddType text/html .jsp
AddHandler jakarta-servlet2 .jsp


Done, save. restart Apache. Now re-install servlets on accounts.

After thats done go back to httpd.conf, and look for this under all the accounts virtualhost

<IfModule mod_jk.c>
JkMount /*.jsp ajp13
JkMount /servlet/* ajp13
JkMount /servlets/* ajp13
</IfModule>
</VirtualHost>

Needs to be:

<IfModule mod_jk2.c>
JkMount /*.jsp ajp13
JkMount /servlet/* ajp13
JkMount /servlets/* ajp13
</IfModule>
</VirtualHost>


Now Tomcat is installed and and should be running, test your install by creating a file named test.jsp and insert the following code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head><title>JSP Test</title></head>
<body>
<h1>JSP Test</h1>
time: <%= new java.util.Date() %>
</body>
</html>


This will show the current date and time if Tomcat is installed correctly like below:
http://www.planetgac.net/test.jsp


*****************************************


Installing the JDBC


cd /usr/local

wget http://dev.mysql.com/get/Downloads/C...s.hoobly.com//

unpack the distribution

now enter the created directory and copy this file:
mysql-connector-java-3.0.9-stable-bin.jar

to your $JAVA_HOME/jre/lib/ext

also I copied it to:
/usr/local/jakarta/jakarta-tomcat-4.1.12-src/build/common/lib

Now just set the classpath in your scripts.

The thing is we have to use
com.mysql.jdbc.Driver

instead of

org.gjt.mm.mysql.Driver

in the command

Class.forName("com.mysql.jdbc.Driver").newInstance ();

So the suggestion code generated by phpMyAdmin for
mySQL

Class.forName("org.gjt.mm.mysql.Driver").newInstan ce();

should be revised to

Class.forName("com.mysql.jdbc.Driver").newInstance ();


TEST IT!

Heres a sample script that shows websites that have visited a page on your site

First create a new database
And the sql for the DB:
CREATE TABLE `t_log` (
`logtime` timestamp(14) NOT NULL,
`ip` varchar(15) NOT NULL default '',
`hostname1` varchar(5) NOT NULL default '_',
`hostname2` varchar(50) NOT NULL default '_',
`uid` bigint(20) NOT NULL default '0',
`actid` tinyint(4) NOT NULL default '0',
`targetid` tinyint(4) NOT NULL default '0',
KEY `logtime`
(`logtime`,`hostname1`,`hostname2`,`uid`)
) TYPE=MyISAM COMMENT='For logging user''s
activities';

And the script that calls the info (Change DBname, user and pass to yours):

<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<%
//Driver DriverSearchResult = (Driver)Class.forName("org.gjt.mm.mysql.Driver").n ewInstance();
Driver DriverSearchResult = (Driver)Class.forName("com.mysql.jdbc.Driver").new Instance();
Connection ConnSearchResult = DriverManager.getConnection("jdbc:mysql://localhost/DBname?user=DBuser&password=password");
PreparedStatement StatementSearchResult = ConnSearchResult.prepareStatement("SELECT * FROM t_log order by logtime desc");
ResultSet SearchResult = StatementSearchResult.executeQuery();
boolean SearchResult_isEmpty = !SearchResult.next();
boolean SearchResult_hasData = !SearchResult_isEmpty;
Object SearchResult_data;
int SearchResult_numRows = 0;
%>
<%
int Repeat1__numRows = -1;
int Repeat1__index = 0;
SearchResult_numRows += Repeat1__numRows;
%>
<html>
<head>
<title>Domain Name Log</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p> The List of Domain Names Visiting the Website <font color="#FF00FF"><strong>planetgac.net/index.shtml</strong></font>:</p>

<table width="100%" border="1">
<tr>
<td width="26%"><strong>Host Name</strong></td>
<td width="74%"><strong>Time</strong></td>
</tr>
<% while ((SearchResult_hasData)&&(Repeat1__numRows-- != 0)) { %>
<tr>
<td><%=(((SearchResult_data = SearchResult.getObject("hostname2"))==null || SearchResult.wasNull())?"":SearchResult_data)%></td>
<td><%=(((SearchResult_data = SearchResult.getObject("logtime"))==null || SearchResult.wasNull())?"":SearchResult_data)%></td>
</tr>
<%
Repeat1__index++;
SearchResult_hasData = SearchResult.next();
}
%>
</table>
</body>
</html>
<%
SearchResult.close();
ConnSearchResult.close();
%>





heres the output:
http://www.planetgac.net/mysqltest.jsp


More info can be found here on setting classpath:
http://www.mysql.com/documentation/c...html#id2800725


Need support? Email me or post questions.


Just a few notes, chkserv.d will probably show Tomcat as failed but all JSP/Servlets work. This is because the chkserv.d file for this release will be no good. I am working on an updated one and will get it here ASAP. In the meantime if you do not want to see the failed Tomcat. Delete the file and reboot server.
__________________
Vision Plateau Web Services - Total Control Hosting
http://www.visionplateau.com

Last edited by Planet_Master; 06-28-2004 at 01:21 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 11-05-2003, 05:59 PM
casey's Avatar
Registered User
 
Join Date: Jan 2003
Location: If there is trouble, it will find me
Posts: 2,335
casey is an unknown quantity at this point
Thank you! I will have to test this out.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 11-07-2003, 01:27 AM
Registered User
 
Join Date: Feb 2003
Posts: 110
infinityws is on a distinguished road
Quote:
<IfModule mod_jk.c>
JkMount /*.jsp ajp13
JkMount /servlet/* ajp13
JkMount /servlets/* ajp13
</IfModule>
</VirtualHost>

Needs to be:

<IfModule mod_jk2.c>
JkMount /*.jsp ajp13
JkMount /servlet/* ajp13
JkMount /servlets/* ajp13
</IfModule>
</VirtualHost>
I created a new account after installing tomcat and added servlets. It didn't work. I looked at the http.conf file and saw that it was missing the mod_jk2.c. Am I gonna have to do this for EVERY JSP account? Manually change this?

(doesn't work either way)
__________________
hiiii
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 11-07-2003, 01:38 AM
Planet_Master's Avatar
Registered User
 
Join Date: Apr 2002
Location: New Yorker
Posts: 260
Planet_Master
Actually I tested it with both:

<IfModule mod_jk.c>
JkMount /*.jsp ajp13
JkMount /servlet/* ajp13
JkMount /servlets/* ajp13
</IfModule>
</VirtualHost>

Needs to be:

<IfModule mod_jk2.c>
JkMount /*.jsp ajp13
JkMount /servlet/* ajp13
JkMount /servlets/* ajp13
</IfModule>
</VirtualHost>

And it works either way.

Make sure you placed all the required lines in httpd.conf and then restart Apache.

Also if using servlets make sure your WEB-INF directory is properly set-up.

Have about 20 accounts using JSP and everything including JDBC works using the same exact steps as above. Re-check your httpd.conf file
__________________
Vision Plateau Web Services - Total Control Hosting
http://www.visionplateau.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 11-07-2003, 01:52 AM
Registered User
 
Join Date: Feb 2003
Posts: 110
infinityws is on a distinguished road
Right now this is a new box, so I have a domain propagating, I wonder if it won't work on the /~username setting.

I'm pretty sure everything is there.

What is the WEB-INF dir?
__________________
hiiii
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 11-07-2003, 02:17 AM
Planet_Master's Avatar
Registered User
 
Join Date: Apr 2002
Location: New Yorker
Posts: 260
Planet_Master
You can run the test.jsp without the WEB-INF directory but to run servlets/class files you need to create a directory in your root called WEB-INF

Create this directory structure in your /public_html directory:

/WEB-INF/classes

Then you can then put servlets in the /classes subdirectory and call them
like so:
http://www.yourdomain.com/servlet/NameOfServlet

chmod the new directories to 755

Also create /WEB-INF/lib

To execute .jars

It would also be better if your domain resolved before testing.
__________________
Vision Plateau Web Services - Total Control Hosting
http://www.visionplateau.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 11-07-2003, 10:15 AM
Registered User
 
Join Date: Apr 2003
Posts: 46
geekhosting
ok probably a dumb question, but any clue on how to fix this?

/etc/init.d/httpd configtest
Create config for main host
Syntax error on line 4 of /usr/local/jakarta/jakarta-tomcat-4.1.12-src/build/conf/auto/mod_jk.conf:
Cannot load /usr/local/apache/libexec/mod_jk.so into server: /usr/local/apache/libexec/mod_jk.so: cannot open shared object file: No such file or directory
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 11-07-2003, 11:29 AM
Registered User
 
Join Date: Apr 2003
Posts: 46
geekhosting
alright, i have looked all over the place for information on mod_jk.so

This lead me to install sun java since it was not there, but i still can not find information on how to compile mod_jk.so which is what is giving me errors.

Can anyone tell me if they had any luck on a cpanel box, and if so where can i find some documentation?

and please do NOT give me google search results as i have spent countless hours googling for my answer already
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 11-07-2003, 06:49 PM
Planet_Master's Avatar
Registered User
 
Join Date: Apr 2002
Location: New Yorker
Posts: 260
Planet_Master
Let me do a bit of looking, i have done this before.
__________________
Vision Plateau Web Services - Total Control Hosting
http://www.visionplateau.com

Last edited by Planet_Master; 04-08-2004 at 08:20 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 11-07-2003, 06:54 PM
Planet_Master's Avatar
Registered User
 
Join Date: Apr 2002
Location: New Yorker
Posts: 260
Planet_Master
I am thinking this can be compiled with Apache. I just received word that Apache version 1.3.29 is available and I will be upgrading later on. I will see if mod_jk.so can be or is in fact compiled with thye upgrade.
__________________
Vision Plateau Web Services - Total Control Hosting
http://www.visionplateau.com

Last edited by Planet_Master; 11-07-2003 at 06:58 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #11 (permalink)  
Old 11-07-2003, 06:58 PM
Registered User
 
Join Date: Apr 2003
Posts: 46
geekhosting
changed and now i get this

/etc/init.d/httpd configtest
Create config for main host
Syntax error on line 4 of /usr/local/jakarta/jakarta-tomcat-4.1.12-src/build/conf/auto/mod_jk.conf:
Can't locate API module structure `jk_module' in file /usr/local/apache/libexec/mod_jk2.so: /usr/local/apache/bin/httpd: undefined symbol: jk_module

so i changed everything to this


<IfModule !mod_jk.c>
LoadModule jk2_module libexec/mod_jk2.so
</IfModule>

Jk2WorkersFile "/usr/local/jakarta/jakarta-tomcat-4.1.12-src/build/conf/jk/workers.properties"
Jk2LogFile "/usr/local/jakarta/jakarta-tomcat-4.1.12-src/build/logs/mod_jk2.log"

Jk2LogLevel emerg

now i get this
Syntax error on line 7 of /usr/local/jakarta/jakarta-tomcat-4.1.12-src/build/conf/auto/mod_jk.conf:
Invalid command 'Jk2WorkersFile', perhaps mis-spelled or defined by a module not included in the server configuration
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12 (permalink)  
Old 11-07-2003, 06:59 PM
Registered User
 
Join Date: Feb 2003
Posts: 110
infinityws is on a distinguished road
I'm using .29.

But I'm gonna wait for a domain to propagate before I report on any final issues with tomcat.
__________________
hiiii
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #13 (permalink)  
Old 11-07-2003, 07:04 PM
Planet_Master's Avatar
Registered User
 
Join Date: Apr 2002
Location: New Yorker
Posts: 260
Planet_Master
Quote:
Originally posted by geekhosting
changed and now i get this

/etc/init.d/httpd configtest
Create config for main host
Syntax error on line 4 of /usr/local/jakarta/jakarta-tomcat-4.1.12-src/build/conf/auto/mod_jk.conf:
Can't locate API module structure `jk_module' in file /usr/local/apache/libexec/mod_jk2.so: /usr/local/apache/bin/httpd: undefined symbol: jk_module

so i changed everything to this


<IfModule !mod_jk.c>
LoadModule jk2_module libexec/mod_jk2.so
</IfModule>

Jk2WorkersFile "/usr/local/jakarta/jakarta-tomcat-4.1.12-src/build/conf/jk/workers.properties"
Jk2LogFile "/usr/local/jakarta/jakarta-tomcat-4.1.12-src/build/logs/mod_jk2.log"

Jk2LogLevel emerg

now i get this
Syntax error on line 7 of /usr/local/jakarta/jakarta-tomcat-4.1.12-src/build/conf/auto/mod_jk.conf:
Invalid command 'Jk2WorkersFile', perhaps mis-spelled or defined by a module not included in the server configuration

Yeah scrap that because I tried it after I posted and it caused Apache to fail on my box at least. Keep it the way it was originally. Damn I know I saw this before and I will find it for you.
__________________
Vision Plateau Web Services - Total Control Hosting
http://www.visionplateau.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #14 (permalink)  
Old 11-07-2003, 07:06 PM
Registered User
 
Join Date: Apr 2003
Posts: 46
geekhosting
will wait for your response

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #15 (permalink)  
Old 11-07-2003, 07:16 PM
Planet_Master's Avatar
Registered User
 
Join Date: Apr 2002
Location: New Yorker
Posts: 260
Planet_Master
Got this from dgbaker over at http://forum.cpanelhosts.com/
Its worth a try.

In some cases for some strange reason the mod_jk.so and mod_jk2.so in /usr/local/apache/libexec end up being the wrong size as so

-rwxr-xr-x 1 root root 148130 Apr 30 18:02 mod_jk2.so*
-rwxr-xr-x 1 root root 129963 Jul 12 19:49 mod_jk.so*

They should be

-rwxr-xr-x 1 root superdb 150601 Aug 27 17:42 mod_jk2.so
-rwxr-xr-x 1 root superdb 130215 Aug 27 18:18 mod_jk.so

If yours ends up being wrong you will know because jsp and servlets will not work through apache and only through tomcat port directly.

You can pick up the modified mod_jk files here http://server11.virtual-hosting.ca/modjk.tar just untar and replace the old ones (back them up first though).
__________________
Vision Plateau Web Services - Total Control Hosting
http://www.visionplateau.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 02:29 PM.


Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© cPanel Inc