首页 > 其他分享 >tomcat 设置 ip 端口访问 以及 多应用设置

tomcat 设置 ip 端口访问 以及 多应用设置

时间:2023-01-12 11:06:48浏览次数:34  
标签:tomcat -- ip 端口 设置 pattern true


Q:web应用想省去应用名,使用ip加端口的方式访问,怎么设置?

A:使用一个巧办法,也是最省力的办法:apache -> conf->server.xml中

<Host name="localhost"  appBase="webapps"
unpackWARs="true" autoDeploy="true">
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<span style="color:#ff0000;"><Context path="" docBase="appname"/></span>
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />

</Host>

这样设置,你就可以使用http://ip:8080 的方式访问自己的应用了。


Q:tomcat 想设置多个应用不同端口访问,怎么设置。

A:tomcat/conf/server.xml 中设置多个sever节点,并复制多个work目录。具体看代码:

<Service name="Catalina">
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8" useBodyEncodingForURI="true"/>
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
</Service>
<Service name="Catalina1">
<Connector port="8081" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8" useBodyEncodingForURI="true"/>
<Engine name="Catalina1" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps1"
unpackWARs="true" autoDeploy="true">

<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
</Service>


我们还需要复制

Catalina --> <span style="font-family:Arial, Helvetica, sans-serif;">Catalina1   </span><pre name="code" class="plain" style="font-family: Arial, Helvetica, sans-serif;">webapps --> <span style="font-family: Arial, Helvetica, sans-serif;">webapps1</span>
<span style="font-family:Arial, Helvetica, sans-serif;">并且清除 work文件夹的内容。</span>



Q:tomcat 想设置多个应用不同端口访问,还要去掉应用名怎么设置。

A:祭出神器设置:<Context path="" docBase="appname"/>


标签:tomcat,--,ip,端口,设置,pattern,true
From: https://blog.51cto.com/u_15939105/6003851

相关文章

  • tomcat ip访问
    1、去除端口号8080。将server.xml中的<Connectorport="8080"protocol="HTTP/1.1"           connectionTimeout="40000" ......
  • pip配置华为加速
    临时使用:pipinstall--trusted-hosthttps://repo.huaweicloud.com-ihttps://repo.huaweicloud.com/repository/pypi/simple安装的包名或者pipinstall-ihttps://......
  • myeclipse python插件安装和环境配置(Windows7下)
    1.下载必备的软件和插件:python:​​http://www.python.org/getit/​​pydev:​​http://pydev.org/download.html​​ 安装python,在myeclipse......
  • ssh-keygen设置密钥登录
    密钥认证过程:1.在ServerA上生成公钥和私钥;2.将公钥拷贝给serverB,要重命名成authorized_keys(必须是这个名字;可以在sshd_config配置文件查看:#AuthorizedKeysFi......
  • javascript集合的使用 new Set()使用
        参考:https://blog.csdn.net/weixin_52941842/article/details/126338193......
  • JavaScript中数组的概念以及创建
     先给大家分享一些JavaScript的相关资料: ​​认识JavaScript到初体验​​​​JavaScript注释以及输入输出语句​​​​JavaScript变量的使用、语法扩展、命名规范​​​......
  • 案例方式学习JavaScript双重for循环
    先给大家分享一些JavaScript的相关资料: ​​认识JavaScript到初体验​​​​JavaScript注释以及输入输出语句​​​​JavaScript变量的使用、语法扩展、命名规范​​​​......
  • JavaScript的for循环学不明白看这篇
    JavaScript相关知识点内容: ​​认识JavaScript到初体验​​​​JavaScript注释以及输入输出语句​​​​JavaScript变量的使用、语法扩展、命名规范​​​​JavaScript数......
  • JavaScript 流程控制-实际案例学习if语句
     JavaScript前文回顾: ​​认识JavaScript到初体验​​​​JavaScript注释以及输入输出语句​​​​JavaScript变量的使用、语法扩展、命名规范​​​​JavaScript数据类......
  • JavaScript:赋值运算符以及运算符优先级
    JavaScript前文回顾: ​​认识JavaScript到初体验​​​​JavaScript注释以及输入输出语句​​​​JavaScript变量的使用、语法扩展、命名规范​​​​JavaScript数据类型......