jdk,tomcat都不需要编译。
tomcat不支持restart
jdk官网http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html
没有jdk,无法编译java程序
tomcat官网http://tomcat.apache.org/
jdk换句话就是java,相当于lamp中的php
tomcat相当于apache
cd /usr/local/src
wget‘http://download.oracle.com/otn-pub/java/jdk/8u91-b14/jdk-8u91-linux-i586.tar.gz?AuthParam=1466748694_4fba144996aad848aa5ee7344c94ad2e‘
tar -zxvf jdk-8u77-linux-i586.gz //文件名字可能不一样
mv jdk1.8.0_77 /usr/local/
vim /etc/profile.d/java.sh
添加内容:
JAVA_HOME=/usr/local/jdk1.8.0_77
JAVA_BIN=/usr/local/jdk1.8.0_77/bin
JRE_HOME=/usr/local/jdk1.8.0_77/jre
CLASSPATH=/usr/local/jdk1.8.0_77/jre/lib:/usr/local/jdk1.8.0_77/lib:/usr/local/jdk1.8.0_77/jre/lib/charsets.jar
PATH=/usr/local/jdk1.8.0_77/bin:/usr/local/jdk1.8.0_77/jre/bin:$PATH
//把$PATH 放到该行的末尾,保证第一个搜索到的java 是自己装的
source /etc/profile.d/java.sh
java -version
//显示自己装的版本就OK
cd /usr/local/src
wget‘http://apache.fayea.com/tomcat/tomcat-7/v7.0.70/bin/apache-tomcat-7.0.70.tar.gz‘
tar -zxvf apache-tomcat-7.0.70.tar.gz
mv apache-tomcat-7.0.70 /usr/local/tomcat
cp /usr/local/tomcat/bin/catalina.sh /etc/init.d/tomcat //拷贝启动脚本
vim /etc/init.d/tomcat
添加内容:
#chkconfig: 2345 63 37
. /etc/init.d/functions
JAVA_HOME=/usr/local/jdk1.8.0_91
CATALINA_HOME=/usr/local/tomcat
chkconfig --add tomcat
chkconfig tomcat on
/etc/init.d/tomcat start
在浏览器输入192.168.134.137:8080可以看到tomcat欢迎页面
vim /usr/local/tomcat/conf/server.xml
找到8080修改了80 //tomcat<!---->表示注释
添加虚拟主机
<Host name="www.111.com"appBase="/data/tomcatweb"
unpackWARs="false" autoDeploy="true"xmlValidation="false"
xmlNamespaceAware="false">
<Contextpath="" docBase="./" debug="0"reloadable="true" crossContext="true"/>
</Host>
//紧接上面的</Host>,其中docBase="./"是相对于appBase="/data/tomcatweb"
mkdir /data/tomcatweb //tomcat家目录,没有它不能启动
/etc/init.d/tomcat stop
/etc/init.d/tomcat start //端口80不要和httpd冲突了
vim /data/tomcatweb/1.jsp
添加内容:
<html><body><center>
Now time is: <%=new java.util.Date()%>
</center></body></html>
curl -xlocalhost:80 www.111.com/1.jsp
显示
<html><body><center>
Now time is: Sat Jun 25 21:25:18 CST 2016
</center></body></html>
//表示tomcat 配置成功
本文出自 “11736718” 博客,请务必保留此出处http://11746718.blog.51cto.com/11736718/1876226
原文:http://11746718.blog.51cto.com/11736718/1876226