简单搭建tomcat 服务

作者: print("") 分类: linux 发布时间: 2017-07-06 16:02


搭建tomcat 

Tomcat 安装环境

 [root@Rserver-1 ~]# cat /etc/redhat-release
CentOS release 6.5 (Final)
[root@Rserver-1 ~]# uname -r
2.6.32-431.el6.x86_64
[root@Rserver-1 ~]# uname -m
x86_64
[root@Rserver-1 ~]#
  http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html 下载java
mkdir /usr/java
[root@Lserver-1 resin-4.0.48]# tar zxf jdk-8u131-linux-x64.tar.gz -C /usr/java
[root@Lserver-1 resin-4.0.48]# vim /etc/profile
JAVA_HOME=”/usr/java/jdk1.8.0_131″
CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
source /etc/profile
[root@Lserver-1 resin-4.0.48]# java -version
java version “1.8.0_131”
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
 
wget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-8/v8.5.15/bin/apache-tomcat-8.5.15.tar.gz tar zxf apache-tomcat-8.5.15.tar.gz
mv apache-tomcat-8.5.15 /usr/local/tomcat
启动tomcat
在/usr/local/tomcat/bin目录下执行./startup.sh,可以看到如下信息:
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
浏览器里输入ip地址:http://**.**.**.**:8080看到可爱的tom猫就表示tomcat搭建ok了! 注意:关于tomcat并没有配置什么环境变量!

优化打开关闭

新建tomcat文件:
#!/bin/bash
TOMCAT=/usr/local/tomcat/bin
case $1 in
start)
sudo sh ${TOMCAT}/startup.sh
;;
stop)
sudo sh ${TOMCAT}/shutdown.sh
;;
restart)
sudo sh ${TOMCAT}/shutdown.sh
sudo sh ${TOMCAT}/startup.sh
;;
*)
echo “Usage: start|stop|restart”
;;
esac
exit 0
增加可执行权限,然后复制到/usr/local/bin
 
测试tomcat
/usr/local/tomcat/webapps  这是tomcat的默认站点
mkdir /usr/local/tomcat/webapps/liang
[root@Rserver-1 liang]# cat index.jsp
<%@ page language=”java” %>
<html>
<head><title>TomcatA</title></head>
<body>
<h1><font color=”red”>TomcatA </h1>
<table align=”centre” border=”1″>
<tr>
<td>Session ID</td>
<% session.setAttribute(“abc”,”abc”); %>
<td><%= session.getId() %></td>
</tr>
<tr>
<td>Created on</td>
<td><%= session.getCreationTime() %></td>
</tr>
</table>
</body>
</html>
 
[root@Rserver-1 liang]#
在网页浏览一下 如果出现如上的情况。说明已经安装成功了。
 

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!

说点什么

avatar
  Subscribe  
提醒