tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David da Guia Carvalho <dg...@animus-ti.com.br>
Subject RE: servlet help
Date Wed, 12 Jan 2005 20:51:42 GMT
Configurando Apache + Jakarta-TOMCAT + Connector MOD_JKConfigurando
Apache + Jakarta-TOMCAT + Connector MOD_JKHi... follow down the
"mini-howto" (Unfortunely I write in portuguese so I have to make a
translation...) I will work on it to translante and correct some
issues... perhaps even in portuguese he can help you....

When I finish the translation I post to you again... (if you need any
help to especific parts mail me!)


Configurando Apache + Jakarta-TOMCAT + Connector MOD_JK
Por: David da Guia Carvalho
Data: 09-09-2004


Consideramos que o leitor possua o seguinte ambiente:
Apache 1.3 ou 2.0; (+DEVEL) + APXS;
J2SDK 1.4;
Jakarta-Tomcat 5.0;
GCC, G++ e DEVEL (LIBS e HEADERS);


Conveção do tutorial:
Letras em Itálico são utilizadas para comandos de Shell;
Letras em courier são utilizadas em conteúdo de arquivos;


Este método foi utilizado repetidamente em DEBIAN 3.0 e Conectiva 10
(Redhat like).
(ambos atualizados na data (09-09-2004)).


APACHE:


A instalação do Apache padrão da distribuição:


Debian: Server version Apache/1.3.26 (Unix) Debian GNU/Linux
nenhuma modificação.


Conectiva: Server Apache/2.0.49
(A única modificação feito foi no arquivo /etc/apache/conf/httpd.conf em
DocummentRoot por motivos de padronização.)
De:
DocumentRoot=/srv/www/default/html
Para:
DocumentRoot=/var/www


( ESTA MODIFICAÇÃO NÃO INFLUENCIA NO FUNCIONAMENTO DO APACHE + TOMCAT )


O JSDK e JAKARTA-TOMCAT:


Em ambas as distribuições instalamos JSDK e TOMCAT em “/opt”.
No arquivo “/etc/profile” foram colocadas as seguintes variáveis que
indicam onde estas aplicações foram instaladas segue abaixo um exemplo:


JAVA_HOME=/opt/j2sdk1.4.2_05
JRE_HOME=/opt/j2sdk1.4.2_05/jre
TOMCAT_HOME=/opt/jakarta-tomcat-5.0.27
export JAVA_HOME
export JRE_HOME
export TOMCAT


Os COMPILADORES:


GCC, G++, LIBS e DEVELS foram instalados segundo o padrão da
distribuição (instalação via apt-get)


Introdução:


Onde obter o arquivo?
Baixe o arquivo: jakarta-tomcat-connectors-jk-1.2.6.src.tar.gz

(http://archieve.apache.org/dist/jakarta/tomcat-connectors/jk/source/jakarta-tomcat-connectors-jk-1.2.6-src.tar.gv)


Instalação:


Descompacte-o em uma pasta de sua escolha (no nosso exemplo utilizaremos
“/usr/src”)


#>tar -zxvf jakarta-tomcat-connectors-jk-1.2.6-src.tar.gz


Entre na pasta que foi criada.


#>cd /usr/src/jakarta-tomcat-connectors-jk-1.2.6-src/jk/native


dentrodo diretorio inicie os preparos para a compilação:


#>./configure –with-apxs=/usr/sbin/apxs


(
Caso necessario o diretorio do apxs pode ser localizado com o comando:
#>locate apxs


Caso nunca tenha utilizado o comando “locate” atualize suas bases de
dadods com o comando:
#>updatedb
)


Após conseguir executar o configure com sucesso execute o comando
“make”:


#>make 


após o comando make copie o arquivo gerado para o diretorio de módulos
do apache (isso varia de distribuição).




PARA DEBIAN 3.0:


#cp
/usr/src/jakarta-tomcat-connectors/jk/native/apache-1.3/mod_jk.so.0.0.0
/usr/lib/apache/1.3/mod_jk.so


PARA CONECTIVA 10:
#cp /usr/src/jakarta-tomcat-connectors/jk/native/apache-2.0/mod_jk.so
/usr/lib/apache/modules


Configurando o Apache:


No diretorio “conf” (para Debian: /etc/apache para Conectiva:
/etc/apache/conf/) do apache, edite o arquivo httpd.conf


Na seção “LoadModule” adicione as seguintes linhas:


PARA DEBIAN:


##############
### Java ###
### TOMCAT ###
##############
LoadFile /usr/lib/libpthread.so
LoadModule jk_module /usr/lib/apache/1.3/mod_jk.so
#AddModule mod_jk.c
JkWorkersFile /opt/jakarta-tomcat-5.0.28/conf/workers.properties
JkLogFile /var/log/apache/mod_jk.log
JkLogLevel debug
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JkRequestLogFormat "%w %V %T"
#
JkMount /*.jsp ajp13
JkMount /servlet/* ajp13
# send all requests ending in .jsp to
# JkMount /*.jsp worker1
# send all requests ending /servlet to worker1
# JkMount /*/servlet/ worker1
# send all requests jsp requests to files located in /otherworker will
go worker2
# JkMount /otherworker/*.jsp worker2


#############################################################






Para CONECTIVA:


##############
### JAVA ###
### TOMCAT ###
##############
#LoadFile /usr/lib/libpthread.so
LoadModule jk_module /usr/lib/apache/modules/mod_jk.so
# AddModule mod_jk.c
JkWorkersFile /opt/jakarta-tomcat-5.0.27/conf/workers.properties
JkLogFile /var/log/apache/mod_jk.log
JkLogLevel debug
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JkRequestLogFormat "%w %V %T"
#
JkMount /*.jsp ajp13
# send all requests ending in .jsp to
# JkMount /*.jsp worker1
# send all requests ending /servlet to worker1
# JkMount /*/servlet/ worker1
# send all requests jsp requests to files located in /otherworker will
go worker2
# JkMount /otherworker/*.jsp worker2
#############################################################


No final do arquivo httpd.conf (tanto p/ conectiva quanto p/ debian)
adicione:


Alias /jsp-examples \
/opt/jakarta-tomcat-5.0.27/webapps/jsp-examples


Configurando o TOMCAT:


Edite (criar caso não exista) o arquivo:
/opt/jakarta-tomcat-5.0.27/conf/worker.properties inserir o seguinte
conteudo:


workers.tomcat_home=/opt/jakarta-tomcat-5.0.27
workers.java_home=/opt/j2sdk1.4.2_05
ps=/
worker.list=ajp13
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
worker.ajp13.lbfactor=1




Finalizando:


Reinicie o TOMCAT:


#>/opt/jakarta-tomcat-5.0.27/bin/shutdown.sh
#>/opt/jakarta-tomcat-5.0.27/bin/startup.sh


Reinicie o Apache:


#>/etc/init.d/apache stop
#>/etc/init.d/apache start


Extra:
(arquivo de inicialização “init.d” do TOMCAT)
Edite (ou crie) o arquivo /etc/init.d/tomcat


#!/bin/sh
#
# Startup script for the Jakarta Tomcat Java Servlets and JSP server
#
# chkconfig: - 85 15
# update-rc
#
# description: Jakarta Tomcat Java Servlets and JSP server
# processname: tomcat
# pidfile: /var/run/tomcat.pid
# config:
# Source function library.
# /etc/rc.d/init.d/functions
# Source networking configuration.
#/etc/sysconfig/network
# Check that networking is up.
# [ ${NETWORKING} = "no" ] && exit 0
# Set Tomcat environment.
# export JAVA_HOME=/usr/local/j2sdk
# export
CLASSPATH=.:/usr/local/j2sdk/lib/tools.jar:/usr/local/j2re/lib/rt.jar
# export CATALINA_HOME=/usr/local/tomcat
# export CATALINA_OPTS="-Dbuild.compiler.emacs=true"
# export PATH=/usr/local/j2sdk/bin:/usr/local/j2re/bin:$PATH
#Var
TOM_DIR="/opt/jakarta-tomcat-5.0.27/";
#JBOSS_DIR="/opt/jboss-3.2.4/";
START_JBOSS="bin/run.sh &"
HALT_JBOSS="bin/shutdown.sh";
START_TOM="bin/startup.sh";
HALT_TOM="bin/shutdown.sh";
#[ -f /usr/local/tomcat/bin/startup.sh ] || exit 0
#[ -f /usr/local/tomcat/bin/shutdown.sh ] || exit 0
# export PATH=$PATH:/usr/bin:/usr/local/bin
# See how we were called.
case "$1" in
start)
# Start daemon.
echo -n "Starting Tomcat: "
$TOM_DIR/$START_TOM;
# $JBOSS_DIR/$START_JBOSS;
# /usr/local/tomcat/bin/startup.sh
RETVAL=$?
echo [ $RETVAL = 0 ] && touch /var/lock/subsys/tomcat
;;
stop)


# Stop daemons.
echo -n "Shutting down Tomcat: "
$TOM_DIR/$HALT_TOM;
# $JBOSS_DIR/$HALT_JBOSS;
# /usr/local/tomcat/bin/shutdown.sh
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/tomcat
;;
restart)
$0 stop
$0 start
;;
condrestart)
[ -e /var/lock/subsys/tomcat ] && $0 restart
;;
status)
status tomcat
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
esac
exit 0


--
------------------------------------------------
David da Guia Carvalho
Animus Tecnologia da Informação
Tel.: (21) 3525-8800
Fax: (21) 3525-8801
http://www.animus-ti.com.br
------------------------------------------------

On Jan 12, 2005 06:16 PM, "Casas, Claudia" <ccasas@utep.edu> wrote:

>Oki doki,
>I got my servlets to work from tomcat using port 8080
>(http://myserver:8080/~myacct/servlet/myservlet), but I still do not
>know how to make apache recognize my servlets and send them to tomcat.
>I
>want to access (http://myserver/~myacct/servlet/myservlet)
>
>I tried to add these lines to httpd.conf
><Location "/servlet/*">
>JkUriSet worker ajp13:localhost:8009
></Location>
>
>and also added these lines to workers2.properties
>
>[uri:spark.iss.utep.edu/servlet/*]
>group=ajp13:localhost:8009
>
>but still no luck! :( please help.
>
>For reference I used the following taken from the web site:
>http://www.jolash.com/tomcat/
>
>Configure the tomcat "web.xml" file in your tomcat's "conf" directory.
>You only need to do this if you are going to write servlets. After
>doing
>this, you can put all your servlets into the subdirectory
>"WEB-INF/classes" of your webapp directory. And you can access those
>servlets with a URL like:
>Uncomment the servlet element tags with the servlet-name of invoker
>(just search for invoker).
><servlet>
><servlet-name>invoker</servlet-name>
><servlet-class>
>org.apache.catalina.servlets.InvokerServlet
></servlet-class>
><init-param>
><param-name>debug</param-name>
><param-value>0</param-value>
></init-param>
><load-on-startup>2</load-on-startup>
></servlet>
>
>Uncomment the servlet-mapping element tags with the servlet-name of
>invoker.
><!-- The mapping for the invoker servlet -->
><servlet-mapping>
><servlet-name>invoker</servlet-name>
><url-pattern>/servlet/*</url-pattern>
></servlet-mapping>
>
>
>-----Original Message-----
>From: Casas, Claudia [mailto:ccasas@utep.edu]
>Sent: Wednesday, January 12, 2005 11:56 AM
>To: tomcat-user@jakarta.apache.org
>Subject: servlet help
>
>
>I am running tomcat5.5.4, apache2.0.52 and jk2.
>1)I an run my jsp's and servlets from root. I have configured tomcat to
>run my jsp's from the homedirs, but I do not know how to configure
>tomcat to run servlets from the homedirs.
>
>I can run my jsp's like this: http://myserver/~myhomedir/myfile.jsp or
>http://myserver:8080/~myhomedir/myfile.jsp
>Either way it works fine.
>What do I need to add so that my servlets run from my homedirs as
>well??
>
>These are my configuration files:
>
>/usr/local/apache/workers2.properties
>
>info=Ajp13 forwarding over socket
>tomcatId=localhost:8009
>
>
>#define the worker
>[ajp13:localhost:8009]
>channel=channel.socket:localhost:8009
>`
># Map the Tomcat examples webapp to the Web server uri space
>#[uri:/jkstatus/*]
>#group=status:status
>
>
>
>
># Uri mapping
>[uri:/jsp-examples/*]
>
>
>[uri:spark.iss.utep.edu/*.jsp]
>group=ajp13:localhost:8009
>
>
>
>I added the following in my httpd.conf also:
>
><Location "/*.jsp">
>JkUriSet worker ajp13:localhost:8009
></Location>
>
>
>(Before I would just add the lines below in my httpd.conf, and jsp's
>and
>servlets would work!
>JkMount /*.jsp ajp13
>JkMount /*/servlet/ ajp13)
>
>
>Also, I have the following in my server.xml file to run my jsp's from
>my
>homedirs:
><Listener className="org.apache.catalina.startup.UserConfig"
>directoryName="wwwdocs"
>userClass="org.apache.catalina.startup.PasswdUserDatabase"/>
>
>What am I missing???
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message