简体   繁体   English

在tomcat 7中配置虚拟主机时出现问题

[英]Issue in configuring virtual host in tomcat 7

I am facing issues in configuring virtual hosts in tomcat 7. 我在tomcat 7中配置虚拟主机时遇到问题。

Till now, I have done the following: 到目前为止,我已经完成了以下工作:

  • Added a Host element in the server.xml file with the appBase as the webapp folder that has my web application. 在具有appBase的server.xml文件中添加了一个Host元素,作为具有我的Web应用程序的webapp文件夹。

     <Host name="www.*myhostname*.com" appBase="my_webapp_folder_name" unpackWARs="true" autoDeploy="true"> <Context docBase="path_of_external_folder" path="/img" /> </Host> 
  • Changed the defaultHost in the Catalina Engine. 在Catalina引擎中更改了defaultHost。

     <Engine name="Catalina" defaultHost="www.*myhostname*.com"> 
  • Created a webapp folder ( my_webapp_folder_name ) in catalina.home. 在catalina.home中创建了一个webapp文件夹( my_webapp_folder_name )。 Also created a ROOT folder inside this webapp folder. 还在此webapp文件夹内创建了一个ROOT文件夹。

  • Copied all the JSPs/HTML, class files, CSS etc inside this ROOT folder. 在此ROOT文件夹中复制了所有JSP / HTML,类文件,CSS等。

  • Created a file ROOT.xml inside the catalina.home/conf/Catalina/myhostname folder with the following contents: 在catalina.home / conf / Catalina / myhostname文件夹内创建了文件ROOT.xml,其内容如下:

     <Context path="" docBase="${catalina.home}/my_webapp_folder_name/ROOT" /> 

Am I missing something here? 我在这里想念什么吗? Because, after doing all the above, I am unable to connect using the host name. 因为完成上述所有操作后,我无法使用主机名进行连接。 But if I type in the IP address of the server, it works fine. 但是,如果我输入服务器的IP地址,则可以正常工作。

I cannot say whether there is any permissions related issue or not. 我不能说是否存在任何与权限相关的问题。

Please help me in resolving this issue. 请帮助我解决此问题。

It must be a matter of name resolution. 这必须是名称解析的问题。 You must be able to resolve the www.myhostname.com. 您必须能够解析www.myhostname.com。

You can add a name record if it is only to develop on your computer: 如果仅在计算机上开发,则可以添加名称记录:

On Windows: 在Windows上:

C:\Windows\System32\drivers\etc\hosts

On Linux: 在Linux上:

/etc/hosts

You can check the resolution with nslookup or dig . 您可以使用nslookupdig检查分辨率。

Otherwise, set up your DNS to resolve www.myhostname.com to your Tomcat bind address. 否则,请设置您的DNS以将www.myhostname.com解析为Tomcat绑定地址。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM