Apache Tomcat is an open source software implementation of the Java Servlet and JavaServer Pages technologies. This post explains the installation and configuration of Tomcat on Ubuntu. I assume the reader to have basic knowledge in Ubuntu.
From Terminal/SSH :
From Terminal/SSH :
-
Run update
sudo apt-get update
-
You can see the list of tomcat packages by issuing a search command
apt-cache search tomcat
-
Install Apache Tomcat using the following command
sudo apt-get install tomcat7
-
Install Java
sudo apt-get install default-jdk
-
Now you have to set environment variables in bashrc
sudo nano ~/.bashrc
Append the following to bashrc (Omit contents after //)export JAVA_HOME=/usr/lib/jvm/default-java
export CATALINA_HOME=/usr/share/tomcat7 //Or tomcat's directory -
Reload bashrc by
. ~/.bashrc
-
Now start tomcat by
sudo /etc/init.d/tomcat7 start
-
If everything was successful
-
sudo /etc/init.d/tomcat7 status
will show a message, "Tomcat Servlet engine is running with pid [some pid]" - Typing server ip address:8080 in your browser will show default response (eg: http://123.456.78.90:8080)
-
Create a index.jsp at /var/lib/tomcat7/webapps/test and write in
<%= "Hello" />
Now typing in http://123.456.78.90:8080/test/index.jsp should show "Hello" (without quotes)
-
-
If you want to change the default port (8080), you have to edit /etc/tomcat7/server.xml
sudo nano /etc/tomcat7/server.xml
Look for<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
Refer Tomcat official site for more information
No comments:
Post a Comment