本文共 1282 字,大约阅读时间需要 4 分钟。
安装tomcat
Tomcat 官网tomcat.apache.orgcd /usr/local/src/wget tar zxvf apache-tomcat-7.0.64.tar.gzmv apache-tomcat-7.0.64 /usr/local/tomcatcp -pv /usr/local/tomcat/bin/catalina.sh /etc/init.d/tomcatvim /etc/init.d/tomcat //从第二行加入1. 2. # chkconfig: 2345 63 373. # description: tomcat server init script4. # Source Function Library5. . /etc/init.d/functions6. JAVA_HOME=/usr/local/jdk1.8.0_317. CATALINA_HOME=/usr/local/tomcat
chmod 755 /etc/init.d/tomcat
chkconfig --add tomcatchkconfig tomcat onservice tomcat startps aux |grep tomcat浏览器输入 可以看到tomcat的欢迎页配置tomcat更改默认启动端口:cd /usr/local/tomcatvim 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>重启:service tomcat stop; service tomcat start测试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>转载于:https://blog.51cto.com/amazing61/2063907