tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jerry Birchler" <jrbirch...@attbi.com>
Subject RE: Jerry!! : How to Apache2, Tomcat4.1.2, JK2 ?
Date Wed, 23 Oct 2002 18:16:53 GMT
Let me know what happens when you try this.

#@>
#@ Red Hat 8.0 includes apache 2.0.40
#@ Let's install apache 2.0.43 as it fixes some bugs and some
vulnerabilities
#@ I had trouble installing newer versions of apache on Red Hat 7.2, so
let's
#@ assume that we are running Red Hat 8.0 already or can upgrade
#@ In this case, we are not creating an RPM package, and we are not
#@ removing the existing one. A cleaner implemention might do that, but this
#@ will enable us to test before doing that.
#@

#@>
#@ Things I do in this document:
#@ -----------------------------
#@ I use the string '#@' to identify documentation and the string '#@>' to
#@ identify the beginning of a block of documentation. I do this because I
#@ include unix commands so that you can cut and paste them as you see fit.
#@ I simply wanted a easy way for you to tell the difference between example
#@ code, commands, etc. and any documentation. The string '#@>' is there for
#@ you to navigate quickly through this document. I use the string '...' to
#@ indicate that I am omitting lines from output or vi for the sake of
reducing
#@ the size of this document. I separate line commands and document blocks
#@ with a blank line.
#@

#@>
#@ Disclaimer:
#@ -----------
#@ First of all, I do not consider myself an expert in tomcat, apache, linux
#@ or open source. As an internet consultant, I spend most of my time
developing
#@ solutions on application servers such as weblogic and iplanet. Like some
of
#@ you, I am simply exploring what I can do with the technology. So, some of
my
#@ suggestions are shortcuts and may not adhere to your idea of best
practices.
#@ My focus was to deliver an example that works.
#@

[root@Linux-2 source]# pwd
/home/admin/installs/source

[root@Linux-2 source]# ls
aspell-0.50.2  httpd-2.0.43  mm-1.2.1  php-4.2.3

[root@Linux-2 source]# cd httpd-2.0.43

[root@Linux-2 httpd-2.0.43] # ./configure
...

[root@Linux-2 httpd-2.0.43] # make
...

[root@Linux-2 httpd-2.0.43] # make install
...

#@>
#@ apache is now in /usr/local/apache2
#@
#@ update lines 24, 24, 26
#@

[root@Linux-2 httpd-2.0.43] # vi /etc/init.d/httpd
...
apachectl=/usr/local/apache2/bin/apachectl
httpd=/usr/local/apache2/bin/httpd
OPTIONS="-f /usr/local/apache2/conf/httpd.conf"
...

#@>
#@ now, test apache
#@

[root@Linux-2 httpd-2.0.43] # /etc/init.d/httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]

#@>
#@ open a browser and hit a bogus url, i.e. http://linux-2/bogus
#@

Not Found
The requested URL /bogus was not found on this server.


----------------------------------------------------------------------------
----

Apache/2.0.43 Server at linux-2 Port 80

#@>
#@ there, proof that we are running apache 2.0.43
#@

#@>
#@ Download the mod_jk-2.0.42.so file from apache.org at
#@
http://jakarta.apache.org/builds/jakarta-tomcat-connectors/jk/release/v1.2.0
/bin/linux/i386/
#@ and then copy it to your apache modules directory and either rename it or
#@ symlink it.
#@
#@ The download site indicates that the module is specific to 2.0.42, but
#@ nonetheless it works. You can download the tomcat connectors source and
#@ build the mod_jk module yourself. I took the easy way out, but to put
things #@ into perspective, it took much more time to document this than it
takes to
#@ download the source, find the directory, read the notes, configure, make
and #@ install it. So, once you get this work, go ahead and build the
mod_jk.so
#@ file for the proper release.
#@

[root@Linux-2 modules]# pwd
/usr/local/apache2/modules

[root@Linux-2 modules]# ls
httpd.exp  jk_jnicb.so  libphp4.so  mod_jk-2.0.42.so

#@>
#@ Again, I like to symlink so that I can keep track of versions. It's not
the
#@ most efficient thing to do, it's just my preference.
#@

[root@Linux-2 modules]# ln -s mod_jk-2.0.42.so mod_jk.so

#@>
#@ Now, let's install and configure tomcat
#@ my preference is to unzip and untar into /opt
#@
#@ Note that I had already installed jdk 1.4.0 in /opt
#@

[root@Linux-2 opt]# pwd
/opt

[root@Linux-2 opt]# ls
j2sdk1.4.0_01  jakarta-tomcat-4.1.12  lost+found  tomcat

#@>
#@ I also like to symlink version specific implementations to
#@ a common name
#@

[root@Linux-2 opt]# ln -s jakarta-tomcat-4.1.12 tomcat

[root@Linux-2 opt]# ln -s j2sdk1.4.0_01 /usr/java

#@>
#@ I like to run tomcat as it's own user
#@ We will use webserv as the user.
#@

[root@Linux-2 opt]# chown -R webserv:webserv /opt/jakarta-tomcat-4.1.12

[root@Linux-2 opt]# chown -R webserv:webserv /opt/tomcat

#@>
#@ I build a wrapper to call catalina.sh so that I can include the init.d
#@ function daemon. I could have doen this from an init.d script, but I
wanted
#@ to run tomcat as webserv instead of root. This was the easy way out.
#@

[root@Linux-2 opt]# cd /opt/tomcat/bin

[root@Linux-2 bin]# vi daemon.sh
#!/bin/sh

. /etc/rc.d/init.d/functions

daemon $CATALINA_HOME/bin/catalina.sh $@
~
~
"/opt/tomcat/bin/daemon.sh" 5L, 82C                           5,1
All

[root@Linux-2 bin]# chmod +x daemon.sh

[root@Linux-2 bin]# vi /etc/init.d/tomcat
#!/bin/sh

start() {
        echo -n $"Starting tomcat: "
        su - webserv -c "$CATALINA_HOME/bin/daemon.sh start"
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && touch /var/lock/subsys/tomcat
}

stop() {
        echo -n $"Stopping tomcat: "
        su - webserv -c "$CATALINA_HOME/bin/daemon.sh stop"
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && rm -f /var/lock/subsys/tomcat /var/run/tomcat.pid
}

. /etc/profile
CLASSPATH=$CATALINA_HOME/common/lib/servlet.jar
export CLASSPATH

case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        start
        stop
        ;;
  *)
        echo $"Usage: tomcat {start|stop|restart}"
        exit 1
esac
~
~
~
"/etc/init.d/tomcat" 37L, 653C                                13,2-9
All

[root@Linux-2 bin]# chmod +x /etc/init.d/tomcat

#@>
#@ Let's create some environment variables
#@ Just add this to the end of /etc/profile
#@

[root@Linux-2 bin]# vi /etc/profile
...
JAVA_HOME=/usr/java
export JAVA_HOME
PATH=$PATH:$JAVA_HOME/bin
export PATH
CATALINA_HOME=/opt/tomcat
export CATALINA_HOME
TOMCAT_HOME=/opt/tomcat
export TOMCAT_HOME
CATALINA_OPTS='-Xms256m -Xmx512m'
export CATALINA_OPTS
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JAVA_HOME/jre/lib/i386/native_threads:$JAV
A_HOME/jre/lib/i386:$JAVA_HOME/jre/lib/i386/client
~
~
"/etc/profile" 67L, 1844C

#@>
#@ Let's create the configuration file for the jk module.
#@ I am going to use the tomcat examples for this example.
#@

[root@Linux-2 conf]# pwd
/opt/tomcat/conf

[root@Linux-2 conf]# ls
catalina.policy  jk2.properties.save           server.xml
jk               mod_jk.conf                   tomcat-users.xml
jk2.properties   server-noexamples.xml.config  web.xml

[root@Linux-2 conf]# vi mod_jk.conf
LoadModule jk_module modules/mod_jk.so

JkWorkersFile "/opt/tomcat/conf/jk/workers.properties"
JkLogFile "/opt/tomcat/logs/mod_jk.log"

JkLogLevel info

#AddModule mod_env.c

JkMount /*.jsp ajp13
JkMount /servlet/* ajp13

JkMount /admin ajp13
JkMount /admin/* ajp13

JkMount /examples ajp13
JkMount /examples/* ajp13

JkMount /examples/servlet/* ajp13
JkMount /examples/jsp/* ajp13
~
~
"mod_jk.conf" 21L, 510C                                       1,9
All

#@>
#@ Create the workers properties file. I got this example from this forum
and
#@ had applied this file originally to an integration of apache 1.13.24 and
#@ tomcat 4.0.4 on red hat 7.2. This file required no changes from that
#@ application.
#@

[root@Linux-2 jk]# vi workers.properties
# ************ Begin worker.properties **************
worker.ajp13.type=ajp13

#
# Specifies the load balance factor when used with
# a load balancing worker.
# Note:
#  ----> lbfactor must be > 0
#  ----> Low lbfactor means less work done by the worker.
worker.ajp13.lbfactor=1

#
# Specify the size of the open connection cache.
worker.ajp13.cachesize=65536

#
#------ DEFAULT LOAD BALANCER WORKER DEFINITION ----------------------
#---------------------------------------------------------------------
#

#
# The loadbalancer (type lb) worker perform weighted round-robin
# load balancing with sticky sessions.
# Note:
#  ----> If a worker dies, the load balancer will check its state
#        once in a while. Until then all work is redirected to peer
#        worker.
worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=ajp13

#
# worker.tomcat_home should point to the location where you
# installed tomcat. This is where you have your conf, webapps and lib
# directories.
#
worker.tomcat_home=/opt/tomcat

#
# worker.java_home should point to your Java installation. Normally
# you should have a bin and lib directories beneath it.
#
worker.java_home=/usr/java

#
# You should configure your environment slash... ps=\ on NT and / on UNIX
# and maybe something different elsewhere.
#
ps=/

#
#------ ADVANCED MODE ------------------------------------------------
#---------------------------------------------------------------------
#

#
#------ DEFAULT worker list ------------------------------------------
#---------------------------------------------------------------------
#
# The worker that your plugins should create and work with
worker.list=ajp13

#
#------ DEFAULT ajp13 WORKER DEFINITION ------------------------------
#---------------------------------------------------------------------
#

#
# Defining a worker named ajp13 and of type ajp13
# Note that the name and the type do not have to match.
#
worker.ajp13.port=8009
worker.ajp13.host=linux-2

# ************ End worker.properties **************
~
~
"workers.properties" 74L, 2039C                               74,1
Bot

#@>
#@ Add an include to the end of the apache configuration file to point to
your
#@ mod_jk configuration file in tomcat.
#@

[root@Linux-2 conf]# pwd
/usr/local/apache2/conf

[root@Linux-2 conf]# vi httpd.conf
...
Include /opt/tomcat/conf/mod_jk.conf
~
~
"httpd.conf" 1057L, 35320C                                    1021,0-1
97%

#@>
#@ We are now ready to test. Let's restart tomcat and then apache.
#@

[root@Linux-2 bin]# /etc/init.d/tomcat restart
Starting tomcat:                                           [  OK  ]
Stopping tomcat:                                           [  OK  ]

[root@Linux-2 httpd-2.0.43] # /etc/init.d/httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]

#@>
#@ I go to http://linux-2/examples/jsp/dates/date.jsp and
#@ here is the output:
#@

Day of month: is 23
Year: is 2002
Month: is October
Time: is 12:10:25
Date: is 10/23/2002
Day: is Wednesday
Day Of Year: is 296
Week Of Year: is 43
era: is 1
DST Offset: is 1
Zone Offset: is -6

#@>
#@ Finally, setup tomcat to automically start up when we boot.
#@

[root@Linux-2 bin]# ln -s /etc/init.d/tomcat /etc/rc0.d/K15tomcat
[root@Linux-2 bin]# ln -s /etc/init.d/tomcat /etc/rc1.d/K15tomcat
[root@Linux-2 bin]# ln -s /etc/init.d/tomcat /etc/rc2.d/K15tomcat
[root@Linux-2 bin]# ln -s /etc/init.d/tomcat /etc/rc3.d/K15tomcat
[root@Linux-2 bin]# ln -s /etc/init.d/tomcat /etc/rc4.d/K15tomcat
[root@Linux-2 bin]# ln -s /etc/init.d/tomcat /etc/rc5.d/K15tomcat
[root@Linux-2 bin]# ln -s /etc/init.d/tomcat /etc/rc5.d/S99tomcat
[root@Linux-2 bin]# ln -s /etc/init.d/tomcat /etc/rc6.d/K15tomcat

#@>
#@ reboot and see if tomcat comes up. I
#@

[root@Linux-2 bin]# init 6






--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message