Skip to content

Instantly share code, notes, and snippets.

@huberflores
Last active December 3, 2015 13:10
Show Gist options
  • Save huberflores/be5495b5464fe6305ec2 to your computer and use it in GitHub Desktop.
Save huberflores/be5495b5464fe6305ec2 to your computer and use it in GitHub Desktop.
Installation of Tomcat along with the JDK
#
# author Huber Flores
#
###Download JDK latest version
Upload the files to the server
put /home/huber/setups/jdk-6u22-linux-i586.bin.zip /home/murakas/huber/software
put /home/huber/setups/apache-tomcat-7.0.4.tar.gz /home/murakas/huber/software
put /home/huber/setups/jdk-6u22-linux-x64.bin /home/murakas/huber/software
Upload the files to the running instance
scp -i huber.private -r /home/murakas/huber/software root@172.17.60.52:/mnt
if files jdk can't be uploaded to the instance then, download it with wget (for example)
$ wget http://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer-Site/en_US/-/USD/VerifyItem-Start/jdk-6u23-linux-x64.bin?BundledLineItemUUID=_qSJ_hCu0VwAAAEtMHlZDcQM&OrderID=7SiJ_hCuYEYAAAEtInlZDcQM&ProductID=6gGJ_hCwIQYAAAEsKIMcKluK&FileName=/jdk-6u23-linux-x64.bin
Installing jdk in an instance on the cloud, jdk which has to be installed on the instance is 64 bits
Method 1
/mnt/jdk-6u22-linux-x64.bin
unzip jdk-6u22-linux-x64.bin
mv jdk1.6.0_22/ /usr/lib
create a symbolic link called jdk to JAVA_HOME
cd /usr/lib
ln -s jdk1.6.0_22 jdk
Now we need to set the JAVA_HOME environment variable. Add the following at the end of /etc/profile just after export PATH.
JAVA_HOME="/usr/lib/jdk"
export JAVA_HOME
Register java command to be use in the command line
update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jdk1.6.0_23/bin/java" 1
update-alternatives --set java /usr/lib/jdk1.6.0_23/bin/java
$java -version
#Trying if java is installed correctly
Method 2
$ chmod +x jdk-6u34-linux-x64.bin
$ sudo ./jdk-6u34-linux-x64.bin
$ sudo mv jdk1.6.0_34 /usr/lib/jvm/
$sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_34/bin/java 1
$ sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_34/bin/javac 1
$ sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.6.0_34/bin/javaws 1
where, 1 is changed to 1064, 1065, etc., it depends on the currents in the system.
$ sudo update-alternatives --config java
$ sudo update-alternatives --config javac
$ sudo update-alternatives --config javaws
###Tomcat installation
Download apache-tomcat-7.0.4.tar.gz or any version you want
Untar the file
Move the folder to your prefered location, in my case, I used /usr/local/tomcat/
Which means that tomcat will start in that location, but to start it will need superuser privileges
Create “tomcat” Group & User
$groupadd tomcat
$useradd -g tomcat -d /usr/local/tomcat tomcat
$usermod -G www-data tomcat
$nano /etc/init.d/tomcat
#command to look for java alternatives
$update-alternatives --config java
#Tomcat auto-start
#description: Auto-starts tomcat
#processname: tomcat
#pidfile: /var/run/tomcat.pid
#this path should point to your JAVA_HOME Directory
export JAVA_HOME=/usr/lib/jdk1.6.0_22/
case $1 in
start)
sh /usr/local/tomcat/apache-tomcat-7.0.4/bin/startup.sh
;;
stop)
sh /usr/local/tomcat/apache-tomcat-7.0.4/bin/shutdown.sh
;;
restart)
sh /usr/local/tomcat/apache-tomcat-7.0.4/bin/shutdown.sh
sh /usr/local/tomcat/apache-tomcat-7.0.4/bin/startup.sh
;;
esac
exit 0
$chmod 755 /etc/init.d/tomcat
$nano /usr/local/tomcat/conf/tomcat-users.xml
add at the end of the file
<role rolename="manager"/>
<role rolename="manager-gui"/>
<role rolename="admin"/>
<user username="admin" password="tomcat" roles="admin,manager,manager-gui"/>
$/etc/init.d/tomcat start
sing CATALINA_BASE: /home/huber/apache-tomcat-7.0.4
Using CATALINA_HOME: /home/huber/apache-tomcat-7.0.4
Using CATALINA_TMPDIR: /home/huber/apache-tomcat-7.0.4/temp
Using JRE_HOME: /usr/lib/jdk1.6.0_22/
Using CLASSPATH: /home/huber/apache-tomcat-7.0.4/bin/bootstrap.jar:/home/huber/apache-tomcat-7.0.4/bin/tomcat-juli.jar
Try tomcat
http://xxx.xxx.xxx.xxx:8080/
Examples working succesfully!!!
http://xxx.xxx.xxx.xxx:8080/examples/servlets/
Application for image in the localhost
http://localhost:8080/Uploader/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment