Tuesday, November 27, 2007

Installing Java and Tomcat (without apache) on base Linux system (Amazon EC2 Fedora Core 4 image)

For YIQYAQ we're running Tomcat as the web server, on basic Linux Fedore Core 4 images at Amazon EC2. These are the steps taken to install Java and Tomcat on those systems and get it running. I'm not much of a Linux, Java, or Tomcat expert, so I can't say these are the best steps to take, only that they're what I did and they seem to work.

  1. Get java from http://java.sun.com/javase/downloads/index.jsp, install JRE self extracting file jre-6u3-linux-i586.bin into the root of the linux system, then follow these command from the linux system
    1. mkdir /java
    2. mv /jre-6u3-linux-i586.bin /java/
    3. cd /java
    4. chmod 555 jre-6u3-linux-i586.bin
    5. ./jre-6u3-linux-i586.bin
    6. rm jre-6u3-linux-i586.bin
  2. Setup Java environment variables
    1. cd ~
    2. nano .bash_profile
    3. add lines
      JAVA_HOME=/java/jre1.6.0_03
      export JAVA_HOME
      JAVAHOME=/java/jre1.6.0_03
      export JAVAHOME
    4. lower down, change from
      PATH=$PATH:$HOME/bin
      to
      PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
    5. exit nano, exit shell, and restart shell to get new environment set up
  3. Download tomcat 6.0.14 from http://tomcat.apache.org/download-60.cgi#6.0.14 to the root of your linux system as apache-tomcat-6.0.14.tar.gz, and follow these commands to install it
    1. mkdir /tomcat
    2. cd /tomcat
    3. mv /apache-tomcat-6.0.14.tar.gz .
    4. gunzip -c apache-tomcat-6.0.14.tar.gz | tar xopf –
    5. rm apache-tomcat-6.0.14.tar.gz
  4. Setup environment variables for tomcat
    1. cd ~
    2. nano .bash_profile
    3. add lines
      CATALINA_HOME=/tomcat/apache-tomcat-6.0.14
      export CATALINA_HOME
    4. exit nano, exit shell, and restart shell to get new environment set up
  5. Test that tomcat is working.
    1. cd ~CATALINA_HOME/bin
    2. ./startup.sh
    3. From browser, verify that http://your-web-domain-address:8080/ returns the default tomcat page
  6. Change tomcat to run on port 80 instead of 8080
    1. cd $CATALINA_HOME
    2. cp conf/server.xml conf/server.xml.original
    3. nano conf/server.xml
    4. replace all 8080 with 80, then exit and save
    5. bin/shutdown.sh
    6. bin/startup.sh
    7. From browser, verify that http://your-web-domain-address/ returns the default tomcat page
  7. Setup manager for Tomcat
    1. nano $CATALINA_HOME/conf/tomcat-users.xml
    2. add this user
      <tomcat-users>
      <role rolename="standard"/>
      <role rolename="manager"/>
      <user username="managername" password="managerpwd" roles="standard,manager"/>
      </tomcat-users>
      replace managername and managerpwd with your real, super-duper top-secret values
    3. restart tomcat
      $CATALINA_HOME/bin/shutdown.sh
      $CATALINA_HOME/bin/shutdown.sh
That's it. All done.

No comments:

Post a Comment