Configurar Tomcat 6, Java 6 en CentOS 5.2 (Con apache en el puerto 8080)
by aristomagnus on Feb.19, 2009, under HowTo - Linux
Tomado de: http://www.satollo.com/english/programming/tomcat-5-java-6-on-centos-52Cambios: Vamos a configurar Tomcat 6
No soy muy experto en la instalaciones de paquetes en linux , pero hoy requiero configurar Tomcat en CentOS 5.2.
CentOS 5.2 tiene Tomcat 6 disponible como un paquete con gcc-java para instalar con yum. Pero los GURUS que me comentan que puedo usar el JDK original de Sun y el tomcat sin problemas.
Tengo conocimiento que Tomcat puede ejecutarse con JRE which is a lot smaller, so I started with download the Java JRE 6 Update 11 from aqui.
I choosed Linux/Multilanguage and accepted the Sun Terms. I downloaded the jre-6u11-linux-i586.bin file wich is an autoinstaller for Linux.
After uploading the file in the /root dir, I did a chmod to make the file executable:
chmod u+x jre-6u11-linux-i586.binand then ran it
./jre-6u11-linux-i586.binI needed to accept the long legal stuff by Sun, inputing a “yes” at the end of the text (press spacebar many time to reach the end).
I got the jre folder that I have to move into /usr or something. Not really satisfying me. Why not to try with an rpm, always from the Sun download page?
The file is called jre-6u11-linux-i586-rpm.bin. Make it executable, run it (as the previous file), accept the legal stuff and you have an rpm which will be automatically installed.
The JRE will e installed in:
/usr/java/jre1.6.0_11/Now it’s time form Tomcat 5. I used the version 5.5.26, not the latest 5.5.27: we have problem with some JSP containing XML fragments which wouldn’t compile.
Tomcat 5 can be download from the archives: pick the file apache-tomcat-5.5.26.tar.gz. Moved it on /root I gunzipped it:
gunzip apache-tomcat-5.5.26.tar.gz // change to tomcat6and then untared (I know Linux guru, all those thing can e done with a single compact command line, but it take more time to read the man pages compared to run two separate and clear commenads).
tar xvf apache-tomcat-5.5.26.tar // change to tomcat6I got the apache-tomcat-5.5.26 folder which I moved to /usr/tomcat. I like the simple things and not the hyper parametric future minded configurations…
mv apache-tomcat-5.5.26 /usr/tomcat // change to tomcat6Now I need some script to run Tomcat as a deman, to put in /etc/init.d. I found this page and modified the script to match my path.
Pay attention: I need Tomcat to run on port 80, so I made it to run as root. If you want to make it run as another user (like tomact) but still responding on port 80, either you need to put in front of it Apache or add some (for me) strange rules to iptables.
tomcat deamon linux bash script
The file needed to be copied in /etc/init.d, and then
chown root:root /etc/init.d/tomcat
chmod a+x /etc/init.d/tomcatTo install the script for various runlevels, I ran
/sbin/chkconfig –add tomcatit will be marked as “on” for runlevel 3, 4, 5 (I’m interest in rulevel 5). To see the configuration of all services, you can run
/sbin/chkconfig –listOn my server Apache was installed and running and I need to stop it to free the port 80. So I marked it as “off” for every runlevel:
/sbin/chkconfig httpd offand then I stopped it:
/etc/init.d/httpd stopNow it’s time to configure and then try to run Tomcat. Firstly I changed the configuration
/usr/tomcat/server.xmlto make it listen to the port 80. Find the string port=”8080″ and change it to port=”80″. Easy.
To run Tomcat has to be configured with the Java path. Remember we are using a JRE so we need to set the environement variable JRE_HOME (not the JAVA_HOME). I did it creating the file “setenv.sh” in /usr/tocat/bin. This file is used by startup and shutdown scripts, without modify them or the catalina.sh script (this is a good practice for future Tomcat upgrade).
The file content will be:
export JRE_HOME=/usr/java/latestThe CATALINA_PID variable force Tomcat to create the pid file of the process, useful to kill it. Note that a shutdown of Tomcat can be done in two way. With the call:
export CATALINA_PID=/var/run/tomcat.pid
/usr/tomcat/bin/shutdownthe same call made from our deamon script, or
/usr/tomcat/bin/shutdown -forcewhich make the script to wait a little and if the process doesn’t terminate it will be killed (using the pid). You can modify the deamon script to shutdown with “force” (I do it everytime).
To start and stop Tomcat:
/etc/init.d/tomcat start
/etc/init.d/tomcat stopYou can also run apache server on another port, for example 8080. You need to change one line on apache config
vi /etc/httpd/conf/httpd.confChange:
Listen 80to
Listen 8080Then start apache:
/etc/init.d/httpd start
No hay comentarios:
Publicar un comentario