|
I recently had to re-install Apache Tomcat on our Ubuntu box, when I realized that version 6 was not available in aptitude. As such, I had to manually install it from a download, and figured I'd share these steps with everybody.
Step 1 - Make Sure Java is Installed Getting Java installed is relatively pain-free. Just run this command: sudo apt-get install sun-java6-jdk
Step 2 - Download the Latest Tomcat Check Tomcat's web site and download the Core binaries
for the latest version of Tomcat (.tar.gz file). Extract this .tar.giz
file to a directory of your choosing, such as /usr/local. For example:
wget http://apache.mirrors.redwire.net/tomcat/tomcat-6/v6.0.18/bin/apache-tomcat-6.0.18.tar.gz tar xvzf apache-tomcat-6.0.18.tar.gz sudo mv apache-tomcat-6.0.18 /usr/local/tomcat
Step 3 - Setup Tomcat to Boot on Startup First,
create the script that will start and stop Tomcat. In this script, you
need to add the JAVA_HOME environment variable which is required by
Tomcat. Optionally, you can also set the CATALINA_BASE variable which
allows you to run multiple Tomcat servers and the CATALINA_OPTS variable which will pass in extra Java Virtual Machine arguments.
sudo nano /etc/init.d/tomcat
Copy and paste this script, making sure to either configure or remove CATALINA_BASE and CATALINA_OPTS:
#!/bin/bash
export JAVA_HOME=/usr/lib/jvm/java-6-sun export CATALINA_BASE=/path/to/catalina/base export CATALINA_OPTS="-server -Xmx512m" 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
Press Ctrl+X to exit, and answer Yes to save. Next, make the script executable, and install it as a startup script:
sudo chmod 755 /etc/init.d/tomcat sudo update-rc.d tomcat defaults
Step 4 - Startup Tomcat and Test Tomcat
should now be properly installed and ready to go. You'll need to
configure Tomcat's server.xml according to your needs, and deploy your
webapp. After you've done that, you can start Tomcat by calling:
sudo /etc/init.d/tomcat start
Tomcat should boot up and you should be able to access your Java app via your web browser.
|