tomcat web project deployment in three ways

First, the use webapps folder automatically deployed

This is the easiest way, as long as the copy directly to the website: webapps tomcat file in the root directory folder

For example: helloworld folder is created in the index.html file, and then helloworld folder to the root directory of tomcat webapps folder and restart tomcat.

Open your browser and tomcat behind the original URL plus / helloworld will automatically open the site

If you do not want to access the content of our project, we must add the project name "helloworld", If you do not want to edit the conf / server.xml configuration.

Open server.xml file, locate the Host element, an increase in the host portion of the content Context:

Restart tomcat and enter the URL in your browser to access the Web site, as shown below, enter tomcat direct URL or URL to index.html

In fact, this is just a trick, use another way to deploy web of direct access, the following will introduce this method

Second,  the use of server.xml deployment project mapping

You can use server.xml configuration file in the conf directory of tomcat deploy web mapping project, the project is not webApp directory deployments up and running.

The specific method is to open the tomcat conf / server.xml, enter the configuration information items between the tag.

Several meanings indicated above configuration parameters are as follows:

path: the path name when the browser visits, such as the first project, browser access path name (mine is port 80): localhost / struts / index.jsp

docBase: Path WebRoot web project is located, note the path WebRoot path, not the project.

debug: a value of 0, it means no print log

reloadble: setting project changes, tomcat whether to re-load the project

Three, Manager Web mode

First visit Apache Tomcat welcome page

我们点击图中圈中的部分,会提示我们输入用户名和密码。所以我们需要在conf/tomcat- users.xml文件里添加角色。tomcat- users.xml默认没有添加任何角色。具体方法参看上一篇博文。登录成功后的页面如下图

Applications下显示了webapps目录下的项目目录:ROOT目录,doc目录,manager目录,这些都是Tomcat自带的。这个时候还没有我们自己的项目。现在我们开始部署自己的项目。在Deploy下,我们看到有两种方式:1.Deploy directory or WAR file located on server;2.WAR file to deploy。

​这里讲解第1种方式,

1.首先在centos的/temp(此路径随意)下创建一个helloworld2的文件夹,在里面新建一个index.html文件,我在html文件里写入了helloworld文字。

2.context path填写你希望的浏览器访问路径:\helloworld2

第二个文本框可以不填

第三个WAR or Directory URL填写真实的项目路径:/temp/helloworld2

点击按钮Deploy

这时可以看到tomcat页面多了刚刚部署的项目

3.在浏览器中输入项目完整地址即:tomcat地址+/helloworld2​,如下图所示,成功显示了html文件

 

如果仔细观察,在Tomcat根目录的\webapps路径下将会自动出现一个名为helloworld2的文件夹,其内容即是/temp/helloworld2的内容,只是名字是helloworld2而已(这就是前面在Context path键入的结果)。

以上说明利用控制台进行部署的实质仍然是利用Tomcat的自动部署。

Guess you like

Origin www.cnblogs.com/tankblog/p/11204277.html