时间:2021-07-01 10:21:17 帮助过:8人阅读
在Linux下配置JSP+TOMCAT+MYSQL环境
1 下载安装文件
1) jdk-1_2_2_017-linux-i586.tar.gz
下载地址http://java.sun.com/products/archive/j2se/1.2.2_017/
2) jakarta-tomcat-4.1.31.tar.gz
下载地址http://apache.freelamp.com/jakarta/tomcat-4/v4.1.31/bin/jakarta-tomcat-4.1.31.tar.gz
3) mysql-connector-java-3.1.6.tar.gz
下载地址http://dev.mysql.com/downloads/connector/j/3.1.html
2 用root身份安装jdk,tomcat,mysql驱动
1) 拷贝安装文件到/usr/local/目录
cp /root/src/jdk-1_2_2_017-linux-i586.tar.gz /usr/local/
cp /root/src/tar -zxvf ./jakarta-tomcat-4.1.31.tar.gz /usr/local/
cp /root/src/tar -zxvf ./mysql-connector-java-3.1.6.tar.gz /usr/local/
2) 解包
cd /usr/local
tar -zxvf ./jdk-1_2_2_017-linux-i586.tar.gz
tar -zxvf ./jakarta-tomcat-4.1.31.tar.gz
tar -zxvf ./mysql-connector-java-3.1.6.tar.gz
3) 删除原安装文件
rm -f ./*.tar.gz
4) 拷贝mysql驱动
cp ./mysql-connector-java-3.1.6/mysql-connector-java-3.1.6-bin.jar ./jakarta-tomcat-4.1.31/webapps/ROOT/WEB-INF/lib/
3 配置JDK环境变量
修改/etc/profile,加入如下几行
JAVA_HOME=/usr/local/jdk1.2.2
JRE=/usr/local/jdk1.2.2/jre
CLASSPATH=$JAVA_HOME/lib:$JRE/lib:/usr/local/jakarta-tomcat-4.1.31/webapps/ROOT/WEB-INF/lib/mysql-connector-java-3.1.6-bin.jar:.
PATH=$PATH:$JAVA_HOME/bin:$JRE/bin:.
export JAVA_HOME JRE CLASSPATH
export PATH
4 启动TOMCAT
/usr/local/jakarta-tomcat-4.1.31/bin/startup.sh
5 关闭TOMCAT
/usr/local/jakarta-tomcat-4.1.31/bin/shutdown.sh
6 写mysql.jsp 测试
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>