基于JSP(Java)程序的驱动器,Java的程序解析,需要安装JDK(Java程序容器)
一、JDK的安装
cd /usr/local/src wget http://download.oracle.com/otn-pub/java/jdk/8u71-b15/jdk-8u71-linux-x64.tar.gz?AuthParam=1454065245_effef4fdba5a5d5835208809705435d4 tar xf jdk-8u71-linux-x64.tar.gz mv jdk1.8.0_71/ /usr/local/
vim /etc/profile.d/java.sh #java环境变量的设置 JAVA_HOME=/usr/local/jdk1.8.0_71 JAVA_BIN=/usr/local/jdk1.8.0_71/bin JRE_HOME=/usr/local/jdk1.8.0._71/jre PATH=$PATH:/usr/local/jdk1.8.0_71/bin:/usr/local/jdk1.8.0.71/jre/bin CLASSPATH=/usr/local/jdk1.8.0_71/jre/lib:/usr/local/jdk1.8.0_71/lib:/usr/local/jdk1.8.0_71/jre/lib/charsets.jar
./etc/profile.d/java.sh #初始化文件 java -version #测试是否安装成功 java version "1.8.0_71" Java(TM) SE Runtime Environment (build 1.8.0_71-b15) Java HotSpot(TM) 64-Bit Server VM (build 25.71-b15, mixed mode)
二、安装Tomcat
cd /usr/local/src wget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-7/v7.0.67/bin/apache-tomcat-7.0.67.tar.gz tar xf apache-tomcat-7.0.67.tar.gz mv apache-tomcat-7.0.67/ /usr/local/tomcat cd /usr/local/tomcat cp -v bin/catalina.sh /etc/init.d/tomcat #复制启动脚本至启动目录
三、编辑配置文件
vim /etc/init.d/tomcat #在#!/bin/bash 目录下添加下面内容 # chkconfig: 2345 63 37 # description: tomcat server init script # Source Function Library ./etc/init.d/functions JAVA_HOME=/usr/local/jdk1.8.0_71 CATALINA_HOME=/usr/local/tomcat chmod 755 /etc/init.d/tomcat chkconfig --add tomcat #配置开机启动 chkconfig tomcat on
vim /usr/local/tomcat/conf/server.xml #找到以下内容,更改端口 <Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> #找到以下</Host>,添加如下配置 <Host name="www.123.cn" appBase="/data/tomcatweb" unpackWARs="false" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> <Context path="" docBase="./" debug="0" reloadable="true" crossContext="true"/> </Host>
mkdir /data/tomcatweb vim /data/tomcatweb/111.jsp <html><body><center> Now time is: <%=new java.util.Date()%> </center></body></html>
测试:
curl -xlocalhost:80 www.123.cn/1.jsp <html><body><center> Now time is: Thu Jan 28 20:53:14 CST 2016 </center></body></html>
本文出自 “卫斯理” 博客,请务必保留此出处http://szk5043.blog.51cto.com/8456440/1831737
原文:http://szk5043.blog.51cto.com/8456440/1831737