日期:2014-05-18  浏览次数:20369 次

急用 如何在linux下配置tomcat和mySQL?
如何在linux下配置tomcat和mySQL?

------解决方案--------------------
mysql
在mysql中增加数据库db9980,加入User,Domain,UserDomain表,数据库适配器的sql语句中注意大小写


drop database if exists db9980;
create database db9980;
use db9980;
drop table if exists User;
create table User
(
userid int unsigned not null AUTO_INCREMENT,
loginid int unsigned,
password varchar(20),
groupid int unsigned,
name varchar(30),
email varchar(40),
phone varchar(20),
info text,
primary key (userid)
);
drop table if exists Domain;
create table Domain
(
domainid int unsigned not null AUTO_INCREMENT,
name varchar(30),
level smallint,
ip varchar(20),
port varchar(10),
primary key (domainid)
);
drop table if exists UserDomain;
create table UserDomain
(
id int unsigned not null AUTO_INCREMENT,
userid int unsigned,
domainid int unsigned,
primary key (id)
);


insert into User (loginid, password) values( '1 ', '1 ');
select * from User limit 0, 5000;


insert into Domain (name, level, ip, port) values( 'luliang ', 1, '10.58.2.2 ', '1099 ');
----------------------
tomcat
在catalina.sh中增加一行:
JAVA_OPTS= "-Djava.security.policy=/home/apache-tomcat-5.5.23/client.policy "
环境变量设置:
export JAVA_HOME=/usr/java/jre1.5.0_04
export BASEDIR=/home
#/apache-tomcat-5.5.23
export CATALINA_HOME=/home/apache-tomcat-5.5.23
DAEMON_HOME=/home/apache-tomcat-5.5.23/bin/jsvc-src
TOMCAT_USER=tomcat
# for multi instances adapt those lines.
#TMP_DIR=/var/tmp
#PID_FILE=/var/run/jsvc.pid
CATALINA_BASE=/home/apache-tomcat-5.5.23
CATALINA_OPTS=
#CATALINA_OPTS= "-Djava.library.path=/home/jfclere/jakarta-tomcat-connectors/jni/native/.libs "
export CLASSPATH=$JAVA_HOME/lib/tools.jar:$CATALINA_HOME/bin/commons-daemon.jar:$CATALINA_HOME/bin/bootstrap.jar

若要访问管理页,需在conf/tomcat-users中增加如下行,才能用admin用户进入:
<user username= "admin " password= " " roles= "admin,manager "/>

------解决方案--------------------
准备软件:
1. J2SDK(1.5.0): jdk-1_5_0-linux-i586-rpm.bin
2. Apache(2.0.53): httpd-2.0.53.tar.gz
3. Resin(3.0.13): resin-3.0.13.tar.gz
4. MySQL(4.1.12): Server: MySQL-server-4.1.12-1.i386.rpm
Client: MySQL-client-4.1.12-1.i386.rpm
5. MySQL-JBDC Connector: mysql-connector-java-3.1.10.tar.gz

将上述软件全部放到一个目录下,假设在/down中.

安装过程:
一.安装J2SDK
1.解压文件,解压后一个RPM安装包,安装中根据提示回答yes即可将文件安装到/usr/java/jdk1.5.0目录中
# chmod u+x ./jdk-1_5_0-linux-i586-rpm.bin
# ./jdk-1_5_0-linux-i586-rpm.bin
# rpm -ivh jdk-1_5_0-linux-i586.rpm
安装程序会将J2SDK安装到以下目录中:
# ls /usr/java
jdk1.5.0

2.配置环境变量
(1)配置用户环境变量
假设用户名为jun,编辑该用户的.bashrc文件:
# vi /home/jun/.bashrc
在其中加入:
export JAVA_HOME=/usr/java/jdk1.5.0
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$CLASSPATH
export PAT