I need to run JavaServer Pages(JSP) in one of my client projects. So, I installed Apache Tomcat server on my Ubuntu. Basically, Apache Tomcat is an open source software implementation for Java Servlet and JSP. I will show you the manual way to install on OpenJDK implementation of Java. You can also run tomcat on Sun’s Java implementation. It’s not so tough. Just follow my steps.
Make sure that your PC has installed Java. If not, then don’t worry. I will show all steps related to install it properly. Open terminal and type following line
sudo apt-get install openjdk-6-jre
Now you can check, weather Java is installed or not. So, type
it will show similar message to the below
java version "1.6.0_20" OpenJDK Runtime Environment (IcedTea6 1.9.7) (6b20-1.9.7-0ubuntu1) OpenJDK 64-Bit Server VM (build 19.0-b09, mixed mode)
Tomcat requires setting the JAVA_HOME variable. So, I edit the ~/.bashrc file by test editor
sudo nano ~/.bashrc
And add the following line . .
Environment is ready for Tomcat server. Now only installing part is left. . . .
You will have to download tomcat from Apache Website. You can download it from the website: http://tomcat.apache.org/download-60.cgi
Or you can download it in commandline
Then extract it on Desktop. Type ..
tar -xvzf apache-tomcat-6.0.32.tar.gz
Move it to the location /usr/local/tomcat
sudo mv apache-tomcat-6.0.32 /usr/local/tomcat
Now you will have to give permission to tomcat directory
sudo chmod -R 755 /usr/local/tomcat
If you want to start tomcat automatically when your PC is started, then you will have to add a script to /etc/init.d.
sudo nano /etc/init.d/tomcat
Just copy and paste following lines…
# Tomcat server auto-start script
case $1 in start) sh /usr/local/tomcat/bin/startup.sh ;; stop) sh /usr/local/tomcat/bin/shutdown.sh ;; restart) sh /usr/local/tomcat/bin/shutdown.sh sh /usr/local/tomcat/bin/startup.sh ;; esac exit 0
Now you will have to make this script executable. So, again you will have to give the permission to the file /etc/init.d/tomcat
sudo chmod 755 /etc/init.d/tomcat
Now, you will have to link this script to the startup folders by a symbolic link. So, just type following commands
sudo ln -s /etc/init.d/tomcat /etc/rc1.d/K99tomcat<br /> sudo ln -s /etc/init.d/tomcat /etc/rc2.d/S99tomcat<br />
Type following line to start the tomcat server
It will show you the following messages . .
Using CATALINA_BASE: /usr/local/tomcat Using CATALINA_HOME: /usr/local/tomcat Using CATALINA_TMPDIR: /usr/local/tomcat/temp Using JRE_HOME: /usr Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar
Done. Your tomcat server is working .. Now Point your browser to : http://localhost:8080
To stop tomcat server, just type
Keep it in your mind, you can also use sun-java-jdk instead of openjdk. Have a happy journey in the open source world !!!