1。安装GDK
官网下载,或者用winscp工具下载后解压
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u73-b02/jdk-8u73-linux-i586.tar.gz
tar zxvf jdk-8u65-linux-x64.tar.gz
mv jdk1.8.0_65 /usr/local/jdk1.8.0_65
vi /etc/profile.d/java.sh //加入如下配置
JAVA_HOME=/usr/local/jdk1.8.0_65
JAVA_BIN=/usr/local/jdk1.8.0_65/bin
JRE_HOME=/usr/local/jdk1.8.0_65/jre
PATH=$PATH:/usr/local/jdk1.8.0_65/bin:/usr/local/jdk1.8.0_65/jre/bin
CLASSPATH=/usr/local/jdk1.8.0_65/jre/lib:/usr/local/jdk1.8.0_65/lib:/usr/local/jdk1.8.0_65/jre/lib/charsets.jar
source /etc/profile.d/java.sh
如果以上配置成功,则下面的命令可以看到java的版本:
java -version
有时候这里要注意删除以前的java
rpm -qa |grep java
错误:
2.安装tomcatcd
/usr/local/src/;
wget http://www.lishiming.net/data/attachment/forum/apache-tomcat-7.0.14.tar.gz
tar zxvf apache-tomcat-7.0.14.tar.gz
mv apache-tomcat-7.0.14 /usr/local/tomcat (tomcat目录不用创建)
cp -p /usr/local/tomcat/bin/catalina.sh /etc/init.d/tomcat
vim /etc/init.d/tomcat //从第二行加入#
# chkconfig: 2345 63 37
# description: tomcat server init script
# Source Function Library
. /etc/init.d/functions
JAVA_HOME=/usr/local/jdk1.8.0_31
CATALINA_HOME=/usr/local/tomcat
chmod 755 /etc/init.d/tomcat
chkconfig --add tomcat
chkconfig tomcat on
service tomcat start
ps aux |grep tomcat
浏览器输入 http://ip:8080 可以看到tomcat的欢迎页
4. 配置tomcat
更改默认启动端口:
cd /usr/local/tomcat
vim conf/server.xml
把Connector port=“8080” 改为 Connector port="80"
配置新虚拟主机:
找到</Host>下一行插入新的<Host>内容如下:
<Host name="www.111.com" appBase="/data/tomcatweb"
unpackWARs="false" autoDeploy="true" xmlValidation="false"
xmlNamespaceAware="false">
<Context path="" docBase="./" debug="0" reloadable="true" crossContext="true"/>
</Host>
mkdir /data/tomcatweb
service tomcat stop; service tomcat start
5. 测试jsp解析
vim /data/tomcatweb/111.jsp //内容如下:
<html><body><center>
Now time is: <%=new java.util.Date()%>
</center></body></html>
curl -xlocalhost:80 www.111.com/111.jsp
看结果是否类似:
<html><body><center>
Now time is: Wed Jan 21 22:33:37 CST 2015
</center></body></html>