第一步:创建项目目录
[root@rabbit-test-1 zhangyu]# mkdir -p /opt/service/
[root@rabbit-test-1 zhangyu]# mkdir -p /opt/logs/tomcat/
第二步:解压并移动到指定目录
[root@rabbit-test-1 zhangyu]# tar -zxf jdk-8u131-linux-x64.tar.gz
[root@rabbit-test-1 zhangyu]# tar -zxf apache-tomcat-8.5.15.tar.gz
[root@rabbit-test-1 zhangyu]# mv jdk1.8.0_131 /opt/service/
[root@rabbit-test-1 zhangyu]# mv apache-tomcat-8.5.15 /opt/service/tomcat
第三步:配置环境变量
[root@rabbit-test-1 zhangyu]# vim /etc/profile
#JDK
export JAVA_HOME=/opt/service/jdk1.8.0_131
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
[root@rabbit-test-1 zhangyu]# source /etc/profile
[root@rabbit-test-1 zhangyu]# 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)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
第四步:配置日志位置及格式
[root@rabbit-test-1 conf]# vim /opt/service/tomcat/conf/server.xml
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="/opt/logs/tomcat/"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %u %t "%r" %s %b %{Referer}i "%{User-Agent}i";" />
#指定catalina.out日志位置【直接加入这句就可以】
[root@rabbit-test-1 conf]# vim /opt/service/tomcat/bin/catalina.sh
第五步:启动tomcat
[root@rabbit-test-1 zhangyu]# /opt/service/tomcat/bin/startup.sh
#停止tomcat
[root@rabbit-test-1 conf]# /opt/service/tomcat/bin/shutdown.sh
第六步:查看进程
[root@rabbit-test-1 conf]# ps -ef |grep tomcat
第七步:测试tomcat启动情况
curl localhost:8080