How to setup a tomcat virtualhost without webapps?

老子叫甜甜 提交于 2019-12-04 13:03:19

To point to your own directory try the following:

go to the tomcat folder %path_to_tomcat%/conf/Catalina/localhost You can also change localhost to your host if you want, but if the only thing you are trying to do is get your app on '/' then localhost is fine.

create a file called ROOT.xml in the previously defined folder. In that file add the following

<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="/home/destiny/www">
</Context>

Also look in %path_to_tomcat%/webapps/, and delete/move/rename the ROOT folder that is there if you don't want the default tomcat page to be there.

See the approach #2 @ this link for more details.

This works for me in Tomcat 7:

<Host name="myhost.com" appBase="">
  <Context path="/" docBase="/home/destiny/www"/>
</Host>

It's probably not the best way to configure Tomcat but it gets a webapp working quickly.

This is sort of an old thread but I wanted to share my experience since this came up in my search results. My issue was upgrading old JSP apps that were exploded in a file structure containing subdirectories on a new server that was using cPanel and an easy tomcat 7 install. Files in subdirectories were not able to reference included files in other directories. Essentially Tomcat was creating a separate context for each subdirectory then I was getting lots of file not found errors on includes.

So I did what Mark suggested with a bit of a change. My server was setup with each virtual host's web document root set to /home/domainuser/public_html and the default tomcat server.xml was setting both the appbase and the context docbase to that directory.

So what finally worked was to "split" up the directory path and put part as the appbase, and then the docbase for my context as the public_html directory. See the example below.

    <Host name="domain.com" appBase="/home/domainuser/" unpackWARs="false" deployXML="false">
      <Alias>www.domain.com</Alias>
      <Context path="" reloadable="true" docBase="public_html" debug="1"/>
   </Host>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!