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

Tomcat部署项目通过—IP地址:端口访问

2016-03-02 14:53 549 查看
如题所示,实现效果图如下:



设置如下:

(1)修改${tomcat}/config/sever.xml文件虚拟内容目录:

<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">

<Context path="" docBase="wmscloud" debug="0" reloadable="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>


这里只需要加入<Content>标签,其他保持默认。Content参数说明:

path是说明虚拟目录的名字,如果你要只输入ip地址就显示主页,则该键值留为空;

docBase是虚拟目录的路径,它默认的是$tomcat/webapps/ROOT目录(需要修改为你的项目名称,上面例子中我的项目名称是wmscloud)。

debug和reloadable一般都分别设置成0和true。

(2)修改${tomcat}/config/sever.xml文件指定Tomcat服务端口:

<Connector port="8080"
maxThreads="150"
minSpareThreads="25"
maxSpareThreads="75"
enableLookups="false"
redirectPort="8443"
acceptCount="100"
debug="0"
connectionTimeout="20000"
disableUploadTimeout="true"
URIEncoding="UTF-8"/>


一般会设置为80端口,但是需要注意端口占用问题。

(3)检查你的欢迎首页设置

修改${tomcat}/config/web.xml ,一般默认使之index.html作为项目访问的首页。

<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>


注:这种设置实际上可以通过项目名称和IP两种形式访问。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: