The Tomcat Host Manager application enables you to create, delete, and otherwise manage virtual hosts within Tomcat. This how-to guide is best accompanied by the following pieces of documentation:html
The Tomcat Host Manager application is a part of Tomcat installation, by default available using the following context: /host-manager. You can use the host manager in the following ways:web
Both ways enable you to add, remove, start, and stop virtual hosts. Changes may be presisted by using the persist command. This document focuses on the text interface. For further information about the graphical interface, see Host Manager App -- HTML Interface.數據庫
在Tomcat的主機管理應用程序,您能夠建立,刪除,不然在Tomcat管理虛擬主機。本操做指南最好附有如下文檔:apache
在Tomcat的主機管理應用程序是Tomcat安裝的一部分,默認狀況下能夠經過以下的背景:/host-manager。您能夠經過如下方式使用主機管理器:tomcat
這兩種方式都容許您添加,刪除,啓動和中止虛擬主機。可使用該persist命令預先進行更改。本文檔重點介紹文本界面。有關圖形界面的更多信息,請參閱 Host Manager App - HTML界面。bash
The description below uses $CATALINA_HOME to refer the base Tomcat directory. It is the directory in which you installed Tomcat, for example C:/tomcat9, or /usr/share/tomcat9.服務器
The Host Manager application requires a user with one of the following roles:app
如下描述$CATALINA_HOME用於引用基本Tomcat目錄。例如C:/tomcat9,它是您安裝Tomcat的目錄,或 /usr/share/tomcat9。
Host Manager應用程序要求用戶具備如下角色之一:less
To enable access to the text interface of the Host Manager application, either grant your Tomcat user the appropriate role, or create a new one with the correct role. For example, open${CATALINA_BASE}/conf/tomcat-users.xml and enter the following:curl
要啓用對Host Manager應用程序的文本界面的訪問,請爲Tomcat用戶授予適當的角色,或者建立具備正確角色的新角色。例如,打開 ${CATALINA_BASE}/conf/tomcat-users.xml並輸入如下內容:
<user username="test" password="chang3m3N#w" roles="admin-script"/>
No further settings is needed. When you now access {server}:{port}/host-manager/text/${COMMAND},you are able to log in with the created credentials. For example:
無需進一步設置。如今訪問時 {server}:{port}/host-manager/text/${COMMAND},您可使用建立的憑據登陸。例如:
$ curl -u ${USERNAME}:${PASSWORD} http://localhost:8080/host-manager/text/list OK - Listed hosts localhost:
Note that in case you retrieve your users using the DataSourceRealm, JDBCRealm, or JNDIRealm mechanism, add the appropriate role in the database or the directory server respectively.
請注意,若是使用,或 機制檢索用戶 DataSourceRealm,請分別在數據庫或目錄服務器中添加適當的角色。 JDBCRealmJNDIRealm
The following commands are supported:
In the following subsections, the username and password is assumed to be test:test. For your environment, use credentials created in the previous sections.
支持如下命令:
在如下小節中,假定用戶名和密碼爲 test:test。對於您的環境,請使用前面部分中建立的憑據。
Use the list command to see the available virtual hosts on your Tomcat instance.
使用list命令查看Tomcat實例上的可用虛擬主機。
Example command:
curl -u test:test http://localhost:8080/host-manager/text/list
Example response:
OK - Listed hosts localhost:
Use the add command to add a new virtual host. Parameters used for the add command:
使用add命令添加新的虛擬主機。用於add命令的參數:
curl -u test:test http://localhost:8080/host-manager/text/add?name=www.awesomeserver.com&aliases=awesomeserver.com&appBase/mnt/appDir&deployOnStartup=true
Example response:
add: Adding host [www.awesomeserver.com]
Use the remove command to remove a virtual host. Parameters used for the remove command:
使用remove命令刪除虛擬主機。用於remove命令的參數:
Example command:
curl -u test:test http://localhost:8080/host-manager/text/remove?name=www.awesomeserver.com
Example response:
remove: Removing host [www.awesomeserver.com]
Use the start command to start a virtual host. Parameters used for the start command:
使用stop命令中止虛擬主機。用於stop命令的參數:
Example command:
curl -u test:test http://localhost:8080/host-manager/text/start?name=www.awesomeserver.com
Example response:
OK - Host www.awesomeserver.com started
Use the stop command to stop a virtual host. Parameters used for the stop command:
使用stop命令中止虛擬主機。用於stop命令的參數:
Example command:
curl -u test:test http://localhost:8080/host-manager/text/stop?name=www.awesomeserver.com
Example response:
OK - Host www.awesomeserver.com stopped
Use the persist command to persist a virtual host into server.xml. Parameters used for the persist command:
使用persist命令將虛擬主機持久保存到 server.xml中。用於persist命令的參數:
This functionality is disabled by default. To enable this option, you must configure the StoreConfigLifecycleListener
listener first. To do so, add the following listener to your server.xml:
默認狀況下禁用此功能。要啓用此選項,必須首先配置StoreConfigLifecycleListener偵聽器。爲此,請將如下偵聽器添加到server.xml:
<Listener className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/>
Example command:
curl -u test:test http://localhost:8080/host-manager/text/persist?name=www.awesomeserver.com
Example response:
OK - Configuration persisted
Example manual entry:
<Host appBase="www.awesomeserver.com" name="www.awesomeserver.com" deployXML="false" unpackWARs="false"> </Host>
聲明,本文內容來自於Apache基金會官網關於Tomcat項目的官方文檔,本人在原文檔內容基礎上整理總結而得,中文翻譯僅供參考,英語不還錯的童鞋,能夠直接去官方查看最新的官方文檔哦!!!若是以爲對你有幫助,不要忘了點贊,評論,轉發喲!!!