您的位置:首页 > 运维架构 > Tomcat

浅谈tomcat

2016-08-11 14:42 211 查看
在tomcat安装目录的confi目录下的server.xml文件是可以配置访问tomcat的端口号,

找到如下代码

<Connector port="8080" protocol="HTTP/1.1" 

               connectionTimeout="20000" 

               redirectPort="8443" />

其中8080是默认的端口可以根据自己的需求去改

还可以在server.xml看到如下代码

<Host name="localhost"  appBase="webapps"

            unpackWARs="true" autoDeploy="true"

            xmlValidation="false" xmlNamespaceAware="false">

其中Host name大家都懂的,appBase是你启动tomcat时访问的部署到tomcat的项目路径,默认是tomcat的webapps文件夹下,但可以自定义目录,需要目录的全名。

下面是

<Context path="" docBase="E:\www\carbbs\carbbs-front"  disableURLRewriting="true"  reloadable="false">

                          <Manager className="org.apache.catalina.session.PersistentManager"

                           saveOnRestart="false">

                           <Store className="org.apache.catalina.session.FileStore"/>

                          </Manager>

         </Context>

例如使用jenkins自动将项目发布到服务器时候,配置的Context 的docBase路径就是发布过来的地方。

tomcat还有其他tomcat-users.xml是配置tomcat的用户名和密码的

例如:

<role rolename="manager-gui"/>  

<role rolename="manager-script"/>  

<role rolename="manager-jmx"/>  

<role rolename="manager-status"/>  

<user username="admin" password="1234" roles="manager-gui,manager-script,manager-jmx,manager-status"/> 

账号是admin密码是1234

标签<role>解释:

manager-gui
允许访问html接口(即URL路径为/manager/html/*)
manager-script
允许访问纯文本接口(即URL路径为/manager/text/*)
manager-jmx
允许访问JMX代理接口(即URL路径为/manager/jmxproxy/*)
manager-status
允许访问Tomcat只读状态页面(即URL路径为/manager/status/*)

如何要看tomcat的日志可以查看logs目录下的localhost_access_log.test文件

要是LInux系统那就更方便了直接一条命令tail -fn300 /usr/local/tomcat-8085/logs/catalina.out 这个是查看8085端口的
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: