在tomcat上配置虚拟主机 [英] configure virtual host on tomcat

查看:37
本文介绍了在tomcat上配置虚拟主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在 tomcat 上运行我的应用程序,url 为 http://localhost:8080/pfaf/test.html.

I am able to run my application on tomcat with url as http://localhost:8080/pfaf/test.html.

在我的应用程序中,我将样式作为/styles/abc.css 访问.打开应用程序时,我在控制台中发现它正在查看 http://localhost:8080/styles 处的 css.当这个应用程序在 WAS 中运行时(它有一个虚拟主机),它工作得很好.

In my application I am accessing the styles as /styles/abc.css. When opening the application I found in console that it is looking the css at http://localhost:8080/styles. where as when this application is running in WAS(it has a virtual host) it works great.

所以有人可以帮我在 tomcat 上创建一个虚拟主机,以便 URL 变为 http://pfaf.localhost:8080/test.html

So can someone please help me in creating a virtual host on tomcat so that URL becomes as http://pfaf.localhost:8080/test.html

提前致谢,

-Ritesh

推荐答案

在 Tomcat 的大多数版本中,包括 Tomcat6 和 Tomcat7,您通过添加一个虚拟主机来添加虚拟主机Host 元素到 server.xml 文件中的 Engine 元素

In most versions of Tomcat, including Tomcat6 and Tomcat7, you add virtual hosts by adding a Host element to the Engine element in the server.xml file

http://tomcat.apache.org/tomcat-7.0-doc/virtual-hosting-howto.html

示例:

   <Host name="pfaf.localhost" appBase="pfaf_webapps"   
        unpackWARs="true" autoDeploy="true"/>

要将 war 文件部署到这个新的虚拟主机,请将其放入 $CATALINA_HOME/pfaf_webapps.

To deploy a war file into this new virtual host, place it into $CATALINA_HOME/pfaf_webapps.

这篇关于在tomcat上配置虚拟主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆