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").newInstance();
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").newInstance();
Driver DriverSearchResult = (Driver)Class.forName("com.mysql.jdbc.Driver").newInstance();
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.



LinkBack URL
About LinkBacks
Reply With Quote





