Pages

Tuesday, June 21, 2011

How to configure Users and Roles in Apache Tomcat 7 and above ?

To configure Users and Roles in Apache Tomcat 7 and above,
follow the following steps.

Once you have downloaded the Apache Tomcat 7, unzip the directory.

The folder structure will be as follows.

root@krishboss[apache-tomcat-7.0.16]#pwd
/opt/apache-tomcat-7.0.16



root@krishboss[apache-tomcat-7.0.16]#ls -l
total 116
drwxr-xr-x 2 root root  4096 2011-06-21 12:54 bin
drwxr-xr-x 3 root root  4096 2011-06-21 13:00 conf
drwxr-xr-x 2 root root  4096 2011-06-21 12:54 lib
-rw-r--r-- 1 root root 56802 2011-06-11 16:06 LICENSE
drwxr-xr-x 2 root root  4096 2011-06-21 12:54 logs
-rw-r--r-- 1 root root  1194 2011-06-11 16:06 NOTICE
-rw-r--r-- 1 root root  8804 2011-06-11 16:06 RELEASE-NOTES
-rw-r--r-- 1 root root  6692 2011-06-11 16:06 RUNNING.txt
drwxr-xr-x 2 root root  4096 2011-06-21 12:54 temp
drwxr-xr-x 7 root root  4096 2011-06-11 16:05 webapps
drwxr-xr-x 3 root root  4096 2011-06-21 12:54 work


change directory to conf folder.

root@krishboss[apache-tomcat-7.0.16]#cd conf/
root@krishboss[conf]#pwd
/opt/apache-tomcat-7.0.16/conf

root@krishboss[conf]#ls -lh
total 196K
drwxr-xr-x 4 root root 4.0K 2011-06-21 13:00 Catalina
-rw------- 1 root root  12K 2011-06-11 16:06 catalina.policy
-rw------- 1 root root 5.1K 2011-06-11 16:06 catalina.properties
-rw------- 1 root root 1.4K 2011-06-11 16:06 context.xml
-rw------- 1 root root 3.1K 2011-06-11 16:06 logging.properties
-rw------- 1 root root 6.4K 2011-06-21 12:56 server.xml
-rw------- 1 root root 1.8K 2011-06-21 13:00
tomcat-users.xml
-rw------- 1 root root 146K 2011-06-11 16:06 web.xml




Edit the tomcat-users.xml file
Just add the following contents to the file and save .

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

<!-- The following tag only contains user name and password-->
  <user username="admin" password="admin" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-gui,admin-script"/>
</tomcat-users>




When ever we change the configuration file, we need to restart Apache Tomcat Server.


To restart the server,
cd bin
sh shutdown.sh
sh startup.sh

Now open the browser and click the following URL.
When prompted, give the user name and password given above.


http://localhost:8000/manager/status

http://localhost:8000/manager/html

http://localhost:8000/host-manager/html

No comments:

Post a Comment