Today we install Tomcat. 

You need a port number (actually two).

http://www.cs.indiana.edu/classes/c212-dgerman/sum2014/hwFive.html

Ruifeng has 17269 (his other port 17169)

You will install the server on your silo account. 

From you machine Start search for PuTTY and then connect to

   silo.cs.indiana.edu

Staci let into her account and here's me as her:

[thompstl@silo ~]$ whoami
thompstl
[thompstl@silo ~]$ pwd
/u/thompstl
[thompstl@silo ~]$

Step 1. Copy Tomcat 7 into your account ---------------------------(Step 01)----------------

cp /l/www/classes/a348/spr2013/software/apache-tomcat-7.0.35.tar.gz ~

Step 2. Unzip the compressed archive

gunzip apache-tomcat-7.0.35.tar.gz

Step 3. Unpack the archive. This creates a folder; move into it (cd apache-tomcat-7.0.35). 

tar xvf apache-tomcat-7.0.35.tar

Here are some examples: 

[thompstl@silo ~]$ pwd
/u/thompstl

That shows you where I am. 

[thompstl@silo ~]$ ls
apache-tomcat-7.0.35  apache-tomcat-7.0.35.tar  bin  httpd  ~httpd  i308  README

This shows you what I have there (first entry is folder created by unpack). 

[thompstl@silo ~]$ rm apache-tomcat-7.0.35.tar
rm: remove regular file `apache-tomcat-7.0.35.tar'? y

Be careful when you remove stuff (use rm -i if your rm is not paranoid as it should be).

[thompstl@silo ~]$ ls
apache-tomcat-7.0.35  bin  httpd  ~httpd  i308  README

So I lost the archive, I don't need it any longer, it was taking up space. 

[thompstl@silo ~]$ cd apache-tomcat-7.0.35/

So this should be the end of this step: moving into the newly created folder. 

[thompstl@silo apache-tomcat-7.0.35]$ pwd
/u/thompstl/apache-tomcat-7.0.35

Where am I: in the new folder it seems. 

[thompstl@silo apache-tomcat-7.0.35]$ ls
bin  conf  lib  LICENSE  logs  NOTICE  RELEASE-NOTES  RUNNING.txt  temp  webapps  work

Oh, look at these files and folder, what do they mean? 

[thompstl@silo apache-tomcat-7.0.35]$ ls -l
total 116
drwx------ 2 thompstl students  4096 Jul 28 12:07 bin
drwx------ 2 thompstl students  4096 Jan 10  2013 conf
drwx------ 2 thompstl students  4096 Jul 28 12:07 lib
-rw------- 1 thompstl students 56812 Jan 10  2013 LICENSE
drwx------ 2 thompstl students  4096 Jan 10  2013 logs
-rw------- 1 thompstl students  1192 Jan 10  2013 NOTICE
-rw------- 1 thompstl students  8826 Jan 10  2013 RELEASE-NOTES
-rw------- 1 thompstl students 16163 Jan 10  2013 RUNNING.txt
drwx------ 2 thompstl students  4096 Jul 28 12:07 temp
drwx------ 7 thompstl students  4096 Jan 10  2013 webapps
drwx------ 2 thompstl students  4096 Jan 10  2013 work
[thompstl@silo apache-tomcat-7.0.35]$

I will have to say that for us these will be the most important: 

     bin

     conf

     logs 

     webapps

Step 4. Move into conf

cd conf

This is a binary installation so all I need to do now is to set it up. 

Check http://silo.cs.indiana.edu:17254/ now, it should not work. 

Use your port number, not Staci's, please.

Step 5. Rename server.xml as I show you below 

[thompstl@silo conf]$ pwd
/u/thompstl/apache-tomcat-7.0.35/conf
[thompstl@silo conf]$ ls -l
total 200
-rw------- 1 thompstl students  12128 Jan 10  2013 catalina.policy
-rw------- 1 thompstl students   6392 Jan 10  2013 catalina.properties
-rw------- 1 thompstl students   1394 Jan 10  2013 context.xml
-rw------- 1 thompstl students   3288 Jan 10  2013 logging.properties
-rw------- 1 thompstl students   6435 Jan 10  2013 server.xml
-rw------- 1 thompstl students   1530 Jan 10  2013 tomcat-users.xml
-rw------- 1 thompstl students 162905 Jan 10  2013 web.xml
[thompstl@silo conf]$ mv server.xml server.xml-backup
[thompstl@silo conf]$ ls -l
total 200
-rw------- 1 thompstl students  12128 Jan 10  2013 catalina.policy
-rw------- 1 thompstl students   6392 Jan 10  2013 catalina.properties
-rw------- 1 thompstl students   1394 Jan 10  2013 context.xml
-rw------- 1 thompstl students   3288 Jan 10  2013 logging.properties
-rw------- 1 thompstl students   6435 Jan 10  2013 server.xml-backup
-rw------- 1 thompstl students   1530 Jan 10  2013 tomcat-users.xml
-rw------- 1 thompstl students 162905 Jan 10  2013 web.xml
[thompstl@silo conf]$

Step 6. Create a new server.xml with this contents: 

<Server port="18631" shutdown="SHUTDOWN">

  <GlobalNamingResources>
    <!-- Used by Manager webapp -->
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
       description="User database that can be updated and saved"
           factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
          pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>

  <Service name="Catalina">
    <Connector port="17631" />

    <Engine name="Catalina" defaultHost="localhost">
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase" />
      <Host name="localhost" appBase="webapps" />
    </Engine>

  </Service>
</Server>

Make sure that you put your port numbers inside, like so:

[thompstl@silo conf]$ pwd
/u/thompstl/apache-tomcat-7.0.35/conf
[thompstl@silo conf]$ pico -w server.xml
[thompstl@silo conf]$ ls -ld server.xml
-rw------- 1 thompstl students 736 Jul 28 12:22 server.xml
[thompstl@silo conf]$ cat server.xml
<Server port="17175" shutdown="SHUTDOWN">

  <GlobalNamingResources>
    <!-- Used by Manager webapp -->
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
       description="User database that can be updated and saved"
           factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
          pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>

  <Service name="Catalina">
    <Connector port="17275" />

    <Engine name="Catalina" defaultHost="localhost">
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase" />
      <Host name="localhost" appBase="webapps" />
    </Engine>

  </Service>
</Server>
[thompstl@silo conf]$

Step 7. Define and set the three environment variables. 

Create a file pico -w ~/tomcat-settings and put this in it:

JAVA_HOME=/usr/lib/jvm/java-1.6.0-sun.x86_64
export JAVA_HOME

CATALINA_HOME=/u/thompstl/apache-tomcat-7.0.35
export CATALINA_HOME

CLASSPATH=.:$CATALINA_HOME/lib/servlet-api.jar
export CLASSPATH

Please use your own username inside for CATALINA_HOME. 

Then source it and you're ready to start your server. 

[thompstl@silo conf]$ pico -w ~/tomcat-settings
[thompstl@silo conf]$ cat ~/tomcat-settings
JAVA_HOME=/usr/lib/jvm/java-1.6.0-sun.x86_64
export JAVA_HOME

CATALINA_HOME=/u/thompstl/apache-tomcat-7.0.35
export CATALINA_HOME

CLASSPATH=.:$CATALINA_HOME/lib/servlet-api.jar
export CLASSPATH
[thompstl@silo conf]$ echo $CATALINA_HOME

[thompstl@silo conf]$ source ~/tomcat-settings
[thompstl@silo conf]$ echo $CATALINA_HOME
/u/thompstl/apache-tomcat-7.0.35
[thompstl@silo conf]$ echo $JAVA_HOME
/usr/lib/jvm/java-1.6.0-sun.x86_64
[thompstl@silo conf]$

Step 8. Start the server. 

[thompstl@silo conf]$ $CATALINA_HOME/bin/startup.sh
Using CATALINA_BASE:   /u/thompstl/apache-tomcat-7.0.35
Using CATALINA_HOME:   /u/thompstl/apache-tomcat-7.0.35
Using CATALINA_TMPDIR: /u/thompstl/apache-tomcat-7.0.35/temp
Using JRE_HOME:        /usr/lib/jvm/java-1.6.0-sun.x86_64
Using CLASSPATH:       /u/thompstl/apache-tomcat-7.0.35/bin/bootstrap.jar:/u/thompstl/apache-tomcat-7.0.35/bin/tomcat-juli.jar
[thompstl@silo conf]$

Step 9. Make the server your own. 

[thompstl@silo conf]$ pico -w /u/thompstl/apache-tomcat-7.0.35/webapps/ROOT/index.html
[thompstl@silo conf]$ pico -w $CATALINA_HOME/webapps/ROOT/index.html
[thompstl@silo conf]$ cat $CATALINA_HOME/webapps/ROOT/index.html
My name is Staci and this is my Tomcat server. <p>

<img src="http://onlinetrendingpics.com/wp-content/uploads/2014/02/funny-puppy-pictures-7.jpg">
[thompstl@silo conf]$