yum install java -y
cd /opt/
wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-8/v8.5.23/bin/apache-tomcat-8.5.23.zip
unzip apache-tomcat-8.5.23.zip
mv apache-tomcat-8.5.23 tomcat
## 添加环境变量
vim /root/.bash_profile
PATH=$PATH:$HOME/bin:/opt/tomcat/bin
##  启动脚本给予权限:
cd /opt/tomcat/bin
chmod 755 *.sh
##  启动tomcat:
./catalina.sh start
##  停止tomcat:
./catalina.sh stop
cd /opt/tomcat/config
cp server.xml server.xml_bak
#注意下面的内容要在<Engine>......</Engine> 之间添加 
<Engine>
  ......
  <Host name="www.21girl.cc"  appBase="/data/www" unpackWARs="true" autoDeploy="true">
            <Valve className="org.apache.catalina.valves.AccessLogValve" directory="/data/logs/"
            prefix="21girl_access_log." suffix=".txt"
            pattern="%h %l %u %t "%r" %s %b" />
            <Context path="" docBase="www.21girl.cc" />
  </Host>
</Engine>
## 项目说明:
name :        需要配置的虚拟主机域名。 如:www.21girl.cc
appBase:       项目代码的父级目录.   如:/data/www/   下面会分目录存放不同工程代码  
unpackWARs:
autoDeploy:   自动部署,检测代码有变动直接刷新
directory:    项目的访问日志存放路径: 默认:tomcat/logs
prefix:        日志名称
suffix:     
pattern:      日志格式
path:       
docBase:      项目代码实际存放的目录,存在于appBase选项的目录之下. 如:  域名www.21girl.cc 的代码存放于/data/www/www.21girl.cc
               或者 对应项目文件夹或者项目的.war包 (如果是war包,就需要把unpackWARs设置为true)
# 创建首页测试文件:
echo "this is www.21girl.cc html" > /data/www/index.html
# 观察日志:
tail -f /data/logs/tail -f 21girl_access_log..2017-11-29.tx
#  客户端访问首页:
curl www.21girl.cc:8080/index.html
#  多个客户端循环访问:
while :;do curl www.21girl.cc ;sleep 2;done
<server>
......
<Service name="Catalina2">
   <Connector port="8082" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
   <Engine name="Catalina2" defaultHost="bbs.21girl.cc">
     <Realm className="org.apache.catalina.realm.UserDatabaseRealm"  
            resourceName="UserDatabase"/>
     <Host name="bbs.21girl.cc"  appBase="/data/www" unpackWARs="true" autoDeploy="true"  
           xmlValidation="false" xmlNamespaceAware="false">
            <Valve className="org.apache.catalina.valves.AccessLogValve" directory="/data/logs/"
            prefix="bbs.21girl_access_log" suffix=".txt"
            pattern="%h %l %u %t "%r" %s %b" />
           <Context path="" docBase="bbs.21girl.cc" />
     </Host>
   </Engine>
 </Service>
# 以上部分
</server>
原文:https://www.cnblogs.com/zhenxing06/p/13084080.html