Upgrading to tomcat 6 and JRE1.6 in Centos 5

First we have to download the latest jre binary from http://java.sun.com/javase/downloads/index.jsp
choose Java SE Runtime Environment (JRE) Update xx then select platform, please select linux or linux x64 depending on your centos version you ‘ve install in your machine. then select [ jre-xxx-linux-xxx.bin] please do not select the rpm one.
to download:
[server]# wget http://xxxxx.jre-xxx-linux-xxx.bin
we have to allow the file to be execute using
[server]# chmod +x jre-xxx-linux-xxx.bin
then extract it using :
[server]# ./jre-xxx-linux-xxx.bin
in the screen appear EULA just press spacebar ’till it ask yes or no, just type yes
then move the extracted folder to /usr/lib/jre1.6.0_xx
[server]# mv jre1.6.0_xx /usr/lib/
then link it to jre directory so u wont have to recreate JAVA_HOME path if u want to upgrade jre later
[server]# ln -s /usr/lib/jre1.6.0_xx /usr/lib/jre
define Java home to that path
[server]# export JAVA_HOME=/usr/lib/jre
java instalation done
then we have to download tomcat 6 from http://tomcat.apache.org/download-60.cgi
choose binary distribution core with tar.gz, type:
[server]# wget http://xxx/bin/apache-tomcat-6.0.xx.tar.gz
extract it with:
[server]# tar -xzf apache-tomcat-6.0.xx.tar.gz
then move it to /opt/tomcat-6
[server]# mv apache-tomcat-6.0.xx /opt/tomcat-6
now create tomcat user so the server wont run it with root priveleges
[server]# adduser -s /sbin/nologin tomcat
[server]# chown -R tomcat. /opt/tomcat-6
[server]# chown -R tomcat. /usr/lib/jre
[server]# export CATALINA_HOME=/opt/tomcat-6
[server]# export CATALINA_BASE=/opt/tomcat-6
[server]# export CATALINA_OPTS=”-Xms512m -Xmx512m”
then we have to add JAVA_HOME, CATALINA_HOME and CATALINA_BASE path to the bottom line of /etc/profile so if u reboot the machine the path is still there
[server]# vi /etc/profile
scrolldown to the end of file then paste this
——————
export JAVA_HOME=/opt/jre
export CATALINA_HOME=/opt/tomcat-6
export CATALINA_BASE=/opt/tomcat-6
export CATALINA_OPTS=”-Xms512m -Xmx512m”
——————–
[server]# /opt/tomcat-6/bin/start.sh
then u can test it with your browser to standard tomcat port 8080
[server]# links http://localhost:8080
or just using your gui browser
if u want tomcat automatically run every time when the machine start
you can add this script /etc/init.d/tomcat
[server]# vi /etc/init.d/tomcat
——————-
#!/bin/bash
# chkconfig: 234 20 80
# description: Tomcat Server basic start/shutdown script
# processname: tomcat
JAVA_HOME=/usr/lib/jre
export JAVA_HOME
export CATALINA_HOME=/opt/tomcat-6
export CATALINA_BASE=/opt/tomcat-6
export CATALINA_OPTS=”-Xms512m -Xmx512m”
TOMCAT_HOME=/opt/tomcat-6/bin
START_TOMCAT=”su - tomcat /opt/tomcat-6/bin/startup.sh”
STOP_TOMCAT=/opt/tomcat-6/bin/shutdown.sh
start() {
echo -n “Starting tomcat: ”
cd $TOMCAT_HOME
${START_TOMCAT}
echo “done.”
}
stop() {
echo -n “Shutting down tomcat: ”
cd $TOMCAT_HOME
${STOP_TOMCAT}
echo “done.”
}
case “$1″ in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 10
start
;;
*)
echo “Usage: $0 {start|stop|restart}”
esac
exit 0
—————–
[server]# chmod +x /etc/init.d/tomcat
[server]# chkconfig ––add tomcat
[server]# chkconfig tomcat on
if u want to use tomcat manager just edit file tomcat-users.xml in tomcat conf folder
[server]# vi /opt/tomcat-6/conf/tomcat-users.xml
then edit user and password
done–
update: limitation using port 8080, we can’t combine it with other services such as ssl and .htaccess, if u want to use tomcat jsp and apache in normal http port (80) follow this instructions
To combine the use of Tomcat JSP and Apache. We may have some PHP scripts and some JSP programs . Using Apache to handle our incoming requests also gives us more options like SSL, error logs, and .htaccess files. we have to edit httpd.conf, make sure mod_proxy.so uncommented, and add something this entries in /etc/httpd/httpd.conf or your other virtualhost conf file this line somewhere under
ProxyPass /tomcat ajp://127.0.0.1:8009/
ProxyPassReverse /tomcat
Referenced from : http://kisunda.blogdetik.com/2008/11/07/omcat-6upgrading-to-t-and-jre16-in-centos-5/
Comments