miércoles, 1 de mayo de 2013

instalar tomcat en centos redhat


##### Instalar JDK en centos 6.0
[root@blanche ~]# mv jdk-6u24-linux-x64.bin /opt/jdk-6u24-linux-x64.bin    
##### Crear el directorio /usr/java
[root@blanche ~]# mkdir /usr/java    
##### Cambiar al directorio /usr/java y ejecutar el comando sh
[root@blanche ~]# cd /usr/java  
[root@blanche java]# sh /opt/jdk-6u24-linux-x64.bin  
##### Define la variable JAVA_HOME path en la shell
[root@blanche java]# JAVA_HOME=/usr/java/jdk1.6.0_24  
[root@blanche java]# export JAVA_HOME  
[root@blanche java]# PATH=$JAVA_HOME/bin:$PATH  
[root@blanche java]# export PATH  
##### Define la variable JAVA_HOME para todos los usuarios, para usuarios especificos ( ~/.bashrc or ~/.bash_profile ) para todos los usuarios /etc/profile
JAVA_HOME=/usr/java/jdk1.6.0_24  
export JAVA_HOME  
PATH=$JAVA_HOME/bin:$PATH  
export PATH  
##### Para comprobar que esta corriendo correctamente ejecute
[root@blanche ~]#  echo $JAVA_HOME  
/usr/java/jdk1.6.0_24  
##### Descarge el instalador de Tomcat 6.0.32:
Download apache-tomcat-6.0.32.tar.gz

##### Comprobar si el archivo descargado coincide con el que genero la empresa tomcat
[root@blanche ~]# md5sum apache-tomcat-6.0.32.tar.gz  
082a0707985b6c029920d4d6d5ec11cd  
[root@blanche ~]# mv apache-tomcat-6.0.32.tar.gz /usr/share/apache-tomcat-6.0.32.tar.gz  
[root@blanche ~]# cd /usr/share  
[root@sv2 blanche ]# tar -xzf apache-tomcat-6.0.32.tar.gz    
[root@blanche share]# cd /usr/share/apache-tomcat-6.0.32/bin
###### Iniciar el demonio del tomcat.sh
[root@blanche bin]# ./startup.sh  
###### crear el archivo tomcat para iniciar/detenet/reiniciar el demonio como root
###### corriendo el demonio tomcat como servicio
[root@blanche share]# cd /etc/init.d  
[root@blanche init.d]# vi tomcat  
######### copie y pege la siguientes lineas 
#!/bin/bash  
# description: Tomcat Start Stop Restart  
# processname: tomcat  
# chkconfig: 234 20 80  
JAVA_HOME=/usr/java/jdk1.6.0_24  
export JAVA_HOME  
PATH=$JAVA_HOME/bin:$PATH  
export PATH  
CATALINA_HOME=/usr/share/apache-tomcat-6.0.32  
  
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  
[root@blanche init.d]# chmod 755 tomcat  
[root@blanche init.d]# chkconfig --add tomcat  
[root@blanche init.d]# chkconfig --level 234 tomcat on  
[root@blanche ~]# service tomcat start  
Using CATALINA_BASE:   /usr/share/apache-tomcat-6.0.32  
Using CATALINA_HOME:   /usr/share/apache-tomcat-6.0.32  
Using CATALINA_TMPDIR: /usr/share/apache-tomcat-6.0.32/temp  
Using JRE_HOME:        /usr/java/jdk1.6.0_24  
Using CLASSPATH:       /usr/share/apache-tomcat-6.0.32/bin/bootstrap.jar  
Stop Tomcat:
[root@blanche ~]# service tomcat stop  
Using CATALINA_BASE:   /usr/share/apache-tomcat-6.0.32  
Using CATALINA_HOME:   /usr/share/apache-tomcat-6.0.32  
Using CATALINA_TMPDIR: /usr/share/apache-tomcat-6.0.32/temp  
Using JRE_HOME:        /usr/java/jdk1.6.0_24  
Using CLASSPATH:       /usr/share/apache-tomcat-6.0.32/bin/bootstrap.jar  
Restarting Tomcat (Must be started first):
[root@blanche ~]# service tomcat restart  
Using CATALINA_BASE:   /usr/share/apache-tomcat-6.0.32  
Using CATALINA_HOME:   /usr/share/apache-tomcat-6.0.32  
Using CATALINA_TMPDIR: /usr/share/apache-tomcat-6.0.32/temp  
Using JRE_HOME:        /usr/java/jdk1.6.0_24  
Using CLASSPATH:       /usr/share/apache-tomcat-6.0.32/bin/bootstrap.jar  
Using CATALINA_BASE:   /usr/share/apache-tomcat-6.0.32  
Using CATALINA_HOME:   /usr/share/apache-tomcat-6.0.32  
Using CATALINA_TMPDIR: /usr/share/apache-tomcat-6.0.32/temp  
Using JRE_HOME:        /usr/java/jdk1.6.0_24  
Using CLASSPATH:       /usr/share/apache-tomcat-6.0.32/bin/bootstrap.jar  
#### observa los logs que se genera en el archivo catalina.out
[root@blanche init.d]# less /usr/share/apache-tomcat-6.0.32/logs/catalina.out  
#### Correr tomcat con usuarios de menores privilegios
#### Crear el grupo tomcat
[root@blanche ~]# groupadd tomcat    
[root@blanche ~]# useradd -g tomcat -d /usr/share/apache-tomcat-6.0.32/tomcat tomcat  
[root@blanche ~]# chown -Rf tomcat.tomcat /usr/share/apache-tomcat-6.0.32/  
[root@blanche ~]# vim /etc/init.d/tomcat 
#!/bin/bash  
# description: Tomcat Start Stop Restart  
# processname: tomcat  
# chkconfig: 234 20 80  
JAVA_HOME=/usr/java/jdk1.6.0_24  
export JAVA_HOME  
PATH=$JAVA_HOME/bin:$PATH  
export PATH  
TOMCAT_HOME=/usr/share/apache-tomcat-6.0.32/bin  
  
case $1 in  
start)  
/bin/su tomcat $TOMCAT_HOME/startup.sh  
;;   
stop)     
/bin/su tomcat $TOMCAT_HOME/shutdown.sh  
;;   
restart)  
/bin/su tomcat $TOMCAT_HOME/shutdown.sh  
/bin/su tomcat $TOMCAT_HOME/startup.sh  
;;   
esac      
exit 0 

No hay comentarios:

 
;