Tomcat is a Java web application server.
This document describes the steps needed to install Apache Tomcat and how to deploy 3rd party web applications in Tomcat.
# pacman -S tomcat
Setting Java Home
There is two Java VM in Arch: OpenJDK JVM and Sun JVM.
Edit file /etc/conf.d/tomcat,
- If you use OpenJDK JVM, set TOMCAT_JAVA_HOME to /usr/lib/jvm/java-6-openjdk, in example:
- If you use Sun JVM, set TOMCAT_JAVA_HOME to /opt/java, in example:
Creating an Admin user
Edit the Tomcat users file to include manager and admin roles with your favorite editor.
# vim /opt/tomcat/conf/tomcat-users.xml
example of tomcat-users.xml file.
<?xml version='1.0' encoding='utf-8'?> <tomcat-users> <role rolename="manager"/> <role rolename="tomcat"/> <role rolename="admin"/> <role rolename="role1"/> <user username="both" password="tomcat" roles="tomcat,role1"/> <user username="tomcat" password="tomcat" roles="tomcat"/> <user username="admin" password="<your_password_here>" roles="admin,tomcat,manager"/> <user username="role1" password="tomcat" roles="role1"/> </tomcat-users> \
As root or with sudo.
# /etc/rc.d/tomcat start
/etc/rc.d/tomcat start :: Starting Tomcat [DONE]
Using your favorite browser go to http://localhost:8080/ for your default Tomcat home page.
note: If this is not working. There is a problem with Tomcat. Check logs from /opt/tomcat/logs/catalina.log
Web application deployment
Download the web application that you want to deploy ( a war file ) and save it to /opt/tomcat/webapps/ folder.
# /etc/rc.d/tomcat restart
Tomcat will ask for your admin <username> and <password>.
Login and check that your war file is listed in the Applications.
If it is listed, click on it to access it.
Hint: Bookmark the webpage for later use.
Problems in deployment
Tomcat should automatically deploy your war file if it is in the /opt/tomcat/webapps/ folder.
If this is not happening you could try to deploy manually.
In the manager page under Deploy click on the "Select WAR file to upload" and select the war file then click on "Deploy".
How to stop Tomcat
As root or with sudo.
# /etc/rc.d/tomcat stop
How to make Tomcat start automatically
add Tomcat in to your /etc/rc.conf DAEMONS line