Before installing Tomcat, make sure you have the Java Runtime Environment installed. You can check this with the following command:
dpkg –get-selections | grep sun-java
If it is not installed, you can see a prior post of mine on how to install it here.
Now that we got that out of the way, enter the following command:
apt-cache search tomcat
Using “apt get install package_name“, you can go ahead and install everything that has “tomcat6” as part of the package name. At this point, “libservlet2.5-java” or a later version should already be installed on your computer; if not, go ahead and install it. The documentation “libservlet2.5-java-doc” probably is not installed so you may want to install it as well. That’s all there is to it. You can also install the packages manually, but I feel this is a much easier way to go about it. You can now start, stop, and restart the Tomcat server using the following commands:
/etc/init.d/tomcat6 start
/etc/init.d/tomcat6 stop
/etc/init.d/tomcat6 restart
Test the application server by using your browser to navigate to “http://localhost:8080”; you should see a default page that gets served-up by the application server. You should also test that the application server and Java Runtime are correctly setup and working well together by creating a simple JSP page and putting it in the “/var/lib/tomcat6/webapps/ROOT” directory. Using your browser, navigate to “http://localhost:8080/your_JSP_page.jsp” and you should see the respective output.