java – 通过命令行在Tomcat中管理Web应用程序

我在RHEL6上配置了Tomcat6.我部署了几个war文件,Web服务器已启动并运行.在适当配置$catalina.home / conf / tomcat-user.xml之后,我可以登录到“Tomcat Web应用程序管理器”,如下所示:

<?xml version='1.0' encoding='utf-8'?>
  <tomcat-users>

   <role rolename="tomcat"/>
   <role rolename="role1"/>
   <user username="tomcat" password="tomcat" roles="tomcat"/>
   <user username="both" password="tomcat" roles="tomcat,role1"/>
   <user username="role1" password="tomcat" roles="role1"/>

   <user name="tomcat" password="password" roles="manager" />

 </tomcat-users>

我使用以下命令来停止“/ httpif”应用程序,但没有工作.

 wget http://tomcat:password@localhost:8080/manager/html/stop?path=/httpif

错误我得到的是未经授权的401.

--2014-03-05 14:28:23--  http://localhost:8080/manager/html/stop?path=/httpif
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:8080... connected.
HTTP request sent, awaiting response... 401 Unauthorized
Authorization failed.

任何人都可以帮助我如何解决这个问题.提前致谢.

最佳答案 尝试将角色manager-gui添加到tomcat用户并将其密码更改为password =“password”

<?xml version='1.0' encoding='utf-8'?>
  <tomcat-users>

   <role rolename="tomcat"/>
   <role rolename="manager-gui"/>
   <user username="tomcat" password="password" roles="tomcat,manager-gui"/>
   <user username="both" password="tomcat" roles="tomcat,role1"/>
   <user username="role1" password="tomcat" roles="role1"/>

 </tomcat-users>
点赞