1.JDK的安装
Tomcat是目前比较流行的Web应用服务器之一
首先安装JDK:
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
解压,移至/usr/local/下
设置环境变量:vim /etc/profile.d/java.sh
JAVA_HOME=/usr/local/jdk1.8.0_101/
JAVA_BIN=/usr/local/jdk1.8.0_101/bin
JRE_HOME=/usr/local/jdk1.8.0_101/jre
PATH=$PATH:/usr/local/jdk1.8.0_101/bin:/usr/local/jdk1.8.0_101/jre/bin
CLASSPATH=/usr/local/jdk1.8.0_101/jre/lib:/usr/local/jdk1.8.0_101/lib:/usr/local/jdk1.8.0_101/jre/lib/charsets.jar
export JAVA_HOME JAVA_BIN JRE_HOME PATH CLASSPATH
检测是否设置正确:
java -version
2.tomcat安装
http://archive.apache.org/dist/tomcat/
下载tomcat:
cd /usr/local/src
wget http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.57/bin/apache-tomcat-7.0.57.tar.gz
拷贝启动脚本并编辑:
mv apache-tomcat-7.0.57 /usr/local/tomcat
cp -p /usr/local/tomcat/bin/catalina.sh /etc/init.d/tomcat
vim /etc/init.d/tomcat
# chkconfig: 112 63 37
# description: tomcat server init script
# Source Function Library
. /etc/init.d/functions
JAVA_HOME=/usr/local/jdk1.8.0_101/
CATALINA_HOME=/usr/local/tomcat
启动tomcat:
/etc/init.d/tomcat start
默认端口:192.168.237.130:8080
3.tomcat虚拟主机配置
cd /usr/local/tomcat/conf
vim server.xml
修改端口为80:
<Connector port="80" protocol="HTTP/1.1"
添加虚拟主机:
<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>
本文出自 “模仿游戏” 博客,请务必保留此出处http://kevinjin117.blog.51cto.com/11655131/1843609
原文地址:http://kevinjin117.blog.51cto.com/11655131/1843609