Linux下配置JSP+TOMCAT+MYSQL环境
添加时间:2015-9-10 2:07:34
添加:
思海网络
在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.*"%>
<html>
<body>
<%Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url ="jdbc:mysql://localhost/phpbb?user=phpbb&password=phpbb&useUnicode=true&characterEncoding=8859_1";
Connection conn= DriverManager.getConnection(url);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="show tables";
ResultSet rs=stmt.executeQuery(sql);%>
<%while(rs.next()) {%>
<%=rs.getString(1)%>
<br>
<%}%>
<%rs.close();
stmt.close();
conn.close();
%>
</body>
</html>
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.*"%>
<html>
<body>
<%Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url ="jdbc:mysql://localhost/phpbb?user=phpbb&password=phpbb&useUnicode=true&characterEncoding=8859_1";
Connection conn= DriverManager.getConnection(url);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="show tables";
ResultSet rs=stmt.executeQuery(sql);%>
<%while(rs.next()) {%>
<%=rs.getString(1)%>
<br>
<%}%>
<%rs.close();
stmt.close();
conn.close();
%>
</body>
</html>
7 外部测试地址http://210.51.1.148:8080/jsp/mysql.jsp
关键字:Linux、TOMCAT、MYSQL
新文章:
- CentOS7下图形配置网络的方法
- CentOS 7如何添加删除用户
- 如何解决centos7双系统后丢失windows启动项
- CentOS单网卡如何批量添加不同IP段
- CentOS下iconv命令的介绍
- Centos7 SSH密钥登陆及密码密钥双重验证详解
- CentOS 7.1添加删除用户的方法
- CentOS查找/扫描局域网打印机IP讲解
- CentOS7使用hostapd实现无AP模式的详解
- su命令不能切换root的解决方法
- 解决VMware下CentOS7网络重启出错
- 解决Centos7双系统后丢失windows启动项
- CentOS下如何避免文件覆盖
- CentOS7和CentOS6系统有什么不同呢
- Centos 6.6默认iptable规则详解