Linux下配置JSP+TOMCAT+MYSQL環(huán)境
添加時(shí)間:2015-9-10 2:07:34
添加:
思海網(wǎng)絡(luò)
在Linux下配置JSP+TOMCAT+MYSQL環(huán)境
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驅(qū)動(dòng)
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驅(qū)動(dòng)
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環(huán)境變量
修改/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 啟動(dòng)TOMCAT
/usr/local/jakarta-tomcat-4.1.31/bin/startup.sh
5 關(guān)閉TOMCAT
/usr/local/jakarta-tomcat-4.1.31/bin/shutdown.sh
6 寫mysql.jsp 測(cè)試
<%@ 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驅(qū)動(dòng)
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驅(qū)動(dòng)
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環(huán)境變量
修改/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 啟動(dòng)TOMCAT
/usr/local/jakarta-tomcat-4.1.31/bin/startup.sh
5 關(guān)閉TOMCAT
/usr/local/jakarta-tomcat-4.1.31/bin/shutdown.sh
6 寫mysql.jsp 測(cè)試
<%@ 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 外部測(cè)試地址http://210.51.1.148:8080/jsp/mysql.jsp
關(guān)鍵字:Linux、TOMCAT、MYSQL
新文章:
- CentOS7下圖形配置網(wǎng)絡(luò)的方法
- CentOS 7如何添加刪除用戶
- 如何解決centos7雙系統(tǒng)后丟失windows啟動(dòng)項(xiàng)
- CentOS單網(wǎng)卡如何批量添加不同IP段
- CentOS下iconv命令的介紹
- Centos7 SSH密鑰登陸及密碼密鑰雙重驗(yàn)證詳解
- CentOS 7.1添加刪除用戶的方法
- CentOS查找/掃描局域網(wǎng)打印機(jī)IP講解
- CentOS7使用hostapd實(shí)現(xiàn)無(wú)AP模式的詳解
- su命令不能切換root的解決方法
- 解決VMware下CentOS7網(wǎng)絡(luò)重啟出錯(cuò)
- 解決Centos7雙系統(tǒng)后丟失windows啟動(dòng)項(xiàng)
- CentOS下如何避免文件覆蓋
- CentOS7和CentOS6系統(tǒng)有什么不同呢
- Centos 6.6默認(rèn)iptable規(guī)則詳解