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
      export JAVA_HOME
      export JAVAHOME
    4. lower down, change from
    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
      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
      <role rolename="standard"/>
      <role rolename="manager"/>
      <user username="managername" password="managerpwd" roles="standard,manager"/>
      replace managername and managerpwd with your real, super-duper top-secret values
    3. restart tomcat
That's it. All done.

Installing ImageMagick with JPEG and PNG Support

ImageMagick is a set of command-line tools for manipulating image files. By default it supports GIF but not the other command interweb formats of JPG (JPEG) and PNG. These are the steps I followed to install ImageMagick on an Amazon EC2 Fedora core-4 Linux image.

This process is also described at Installing ImageMagick with JPEG, TIFF and PNG Support, but I had some problems with a couple of the commands there, it was using files older than the current, and it included TIFF support which I don't expect to be using.

The first step was to get the required source files for each of the components required. These are the files I retrieved, and the web addresses were I retrieved them. (Note, the exact version numbers change over time.) Each of the .tar.gz files I downloaded and copied to the /usr/local/src directory of my EC2 linux system.
from my linux image I then performed these commands (and in this order) to unpack, compile, and install the components and ImageMagick.
  1. cd /usr/local/src
  2. gunzip -c zlib-1.2.3.tar.gz | tar xvf -
  3. rm zlib-1.2.3.tar.gz
  4. cd zlib-1.2.3
  5. ./configure
  6. make
  7. make install
  8. cd /usr/local/src
  9. gunzip -c libpng-1.2.23.tar.gz | tar xvf -
  10. rm libpng-1.2.23.tar.gz
  11. cd libpng-1.2.23
  12. ./configure
  13. make
  14. make install
  15. cd /usr/local/src
  16. gunzip -c jpegsrc.v6b.tar.gz | tar xvf -
  17. rm jpegsrc.v6b.tar.gz
  18. cd jpeg-6b
  19. ./configure --enable-shared
  20. make
  21. make install
    [may need to create man directories]
  22. cd /usr/local/src
  23. gunzip -c ImageMagick.tar.gz | tar xvf -
  24. rm ImageMagick.tar.gz
  25. cd ImageMagick-6.3.7
  26. ./configure
    [verify that jpeg and png are on]
  27. make
  28. make install
Now run a simple test to see that ImageMagick is working
  1. cd /
  2. identify –list Format
    [verify that jpeg and png are on]
  3. convert logo: logo.gif
  4. convert logo: logo.jpg
  5. convert logo: logo.png
    [verify with separate viewer that this images are all OK]
That's it. The ImageMagick command are now ready.

Installing GCC on Amazon EC2 fedora core 4 base

I'm using the ec2-public-images/fedora-core4-base.manifest.xml image on Amazon's EC2 system. (I don't know how this differs from the develop-image.manifest.xml, but wanted to start with something as basic as possible).

This image comes without a GCC compiler. There's almost nothing you can make out of Linux without a compiler.

Adding a compiler is a piece of cake with this command
    yum install gcc
That's it. super easy. You can find more about yum (such as yum update) here.