Install Tomcat7 on EC2
Tomcat7 is not available in the yum Repo on EC2. So this is how installed tomcat 7 on my RHEL 6.4 EC2 instance:
First, I wanted oracle jdk.
Oracle JDK installation:
Remove any existing JDKs
# rpm -qa | grep jdk
java-1.6.0-openjdk-1.6.0.0-1.62.1.11.11.90.el6_4.x86_64
java-1.7.0-openjdk-1.7.0.25-2.3.10.4.el6_4.x86_64
# rpm -e java-1.6.0-openjdk-1.6.0.0-1.62.1.11.11.90.el6_4.x86_64 java-1.7.0-openjdk-1.7.0.25-2.3.10.4.el6_4.x86_64
Download and Install Oracle JDK
# wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F" "http://download.oracle.com/otn-pub/java/jdk/7u45-b18/jdk-7u45-linux-x64.rpm"
# mv jdk-7u45-linux-x64.rpm\?AuthParam\=1385533795_9ebb9bbbd4d15a8ca5d17a0dab41fedc jdk-7u45-linux-x64.rpm
# rpm -ivh jdk-7u45-linux-x64.rpm
Verification
# java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
# javac -version
javac 1.7.0_45
Set JAVA_HOME
# echo "export JAVA_HOME=/usr/java/default" >> /etc/profile
# source /etc/profile
Tomcat 7 Installation:
Download Tomcat
# wget http://www.trieuvan.com/apache/tomcat/tomcat-7/v7.0.47/bin/apache-tomcat-7.0.47.tar.gz
# tar -xvzf apache-tomcat-7.0.47.tar.gz
# mv apache-tomcat-7.0.47 /usr/share/
Make tomcat run as a script.
# cat > /etc/init.d/tomcat < EOF
#!/bin/bash
# description: Tomcat Start Stop Restart
# processname: tomcat
# chkconfig: 234 20 80
JAVA_HOME=/usr/java/default
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
CATALINA_HOME=/usr/share/apache-tomcat-7.0.47/
case $1 in
start)
sh $CATALINA_HOME/bin/startup.sh
;;
stop)
sh $CATALINA_HOME/bin/shutdown.sh
;;
restart)
sh $CATALINA_HOME/bin/shutdown.sh
sh $CATALINA_HOME/bin/startup.sh
;;
esac
exit 0
EOF
Tomcat service commands:
# chmod 755 /etc/init.d/tomcat
# chkconfig --add tomcat
# chkconfig tomcat on
# chkconfig --list tomcat
# service tomcat start
Using CATALINA_BASE: /usr/share/apache-tomcat-7.0.47
Using CATALINA_HOME: /usr/share/apache-tomcat-7.0.47
Using CATALINA_TMPDIR: /usr/share/apache-tomcat-7.0.47/temp
Using JRE_HOME: /usr/java/default
Using CLASSPATH: /usr/share/apache-tomcat-7.0.47/bin/bootstrap.jar:/usr/share/apache-tomcat-7.0.47/bin/tomcat-juli.jar
Add JAVA_OPTS
as below on 2nd line on /usr/share/apache-tomcat-7.0.47/bin/catalina.sh
so that it looks like:
#!/bin/sh
JAVA_OPTS="-Xms1024m -Xmx2048m"
Restart Tomcat
# service tomcat restart
Verification:
# netstat -anp | grep 8080
tcp 0 0 :::8080 :::* LISTEN 1792/java
You can configure tomcat to be run a normal user as well. It wasn't needed in my case and hence I did not do it. Hope this helps.
Related videos on Youtube
Comments
-
Adrian Ber over 1 year
I'm trying to install Tomcat7 on an Amazon EC2 instance, but it doesn't work. Below is the console output:
[ec2-user@ip-XXX ~]$ sudo yum install tomcat7 Loaded plugins: amazon-id, rhui-lb, security Setting up Install Process No package tomcat7 available. Error: Nothing to do
Additionally I would also like to install the Tomcat connector native libraries.
[ec2-user@ip-XXX ~]$ sudo yum repolist Loaded plugins: amazon-id, rhui-lb, security rhui-REGION-client-config-server-6 | 2.6 kB 00:00 rhui-REGION-rhel-server-releases | 3.7 kB 00:00 rhui-REGION-rhel-server-releases-optional | 3.5 kB 00:00 repo id repo name status rhui-REGION-client-config-server-6 Red Hat Update Infrastructure 2.0 Client Configuration Server 6 5 rhui-REGION-rhel-server-releases Red Hat Enterprise Linux Server 6 (RPMs) 11,976 rhui-REGION-rhel-server-releases-optional Red Hat Enterprise Linux Server 6 Optional (RPMs) 6,833 repolist: 18,814 [ec2-user@ip-XXX ~]$ sudo yum list tomcat7* Loaded plugins: amazon-id, rhui-lb, security Error: No matching Packages to list
-
kernelpanic over 10 yearsCan you post the output of "sudo yum repolist" and "sudo yum list tomcat7*"?
-
Adrian Ber over 10 yearsI added the output to the question
-
-
Jack ilkgu about 9 yearsI'm afraid this doesn't help the OP, tomcat7 does not appear in the output of the search command above. Consider adding information that would benefit the OP to solve the posted problem.
-
Rostyslav Druzhchenko over 5 yearsMany thanks for such a detailed and working description