RE: Mod_jk + Apache on RHEL3 gives 503 for jsp only
Here's a quick writeup. This is going to be a long reply, and I hope it will be useful. I am using Fedora Core 4 as a model. I hope it will be close enough to RHEL 3 to be useful. You may have to change paths in order to correspond to your environment. First of all, my environment: Hardware/OS === Dell 8200 with 768 MB memory Dual boot: Fedora Core 4 2.6.13-1.1526_FC4 Windows 2000 Professional Software Java 1.5.0_4 from Sun Apache 2.0.54 from RPM Tomcat 5.5.9 from jakarta.apache.org mod_jk 1.2.14.1 from source Installation Java 1.5.0_4 is installed in /usr/jdk1.5.0_04 and soft linked to /usr/java JAVA_HOME is set in /etc/profile $JAVA_HOME/bin is placed in $PATH before /usr/bin I've left the Apache RPM install alone, which means the following: DocumentRoot /var/www Logs /etc/logs soft linked to /var/log/httpd modules /etc/modules soft linked to /usr/lib/httpd/modules conf /etc/conf /etc/conf.d I've created a tomcat user with the same group membership as apache user. The home directory is /home/tomcat. /home/tomcat/jakarta-tomcat-5.5.9 Current Tomcat installation Configuration = workers.properties -- I've placed workers.properties in /etc/httpd/conf # # basic worker list # worker.list=local,status # # one to serve the applications # worker.local.type=ajp13 worker.local.host=localhost worker.local.port=8009 # # one to check the status # worker.status.type=status worker.status.host=localhost worker.status.port=8009 This is all you really need in order to connect a local Apache to a local Tomcat. I cannot think of a good reason to define more workers. That isn't to say that there aren't any. server.xml -- If you put multiple workers going to the same host and different ports, then you will have to modify server.xml. Basically, you will have to add a connector statement for each unique port that you use in your workers.properties file. You have two different ports, so you will need two connector statements. jk.conf --- I'm following the examples used by Fedora Core 4 in configuring other add-on modules for Apache. You can place the mod_jk configuration information directly in /etc/httpd/conf/httpd.conf, but I've chosen to create a separate file in /etc/httpd/conf.d The contents of my file are as follows: # # following Fedora's add-on philosophy # LoadModulejk_module modules/mod_jk.so JkWorkersFile /etc/httpd/conf/workers.properties JkLogFile logs/mod_jk.log JkLogLevelwarn JkLogStampFormat "[%a %b %d %H:%M:%S %Y] " JkShmFile logs/shm-file # # jk status # JkMount /jk-status/ status httpd.conf -- Static File Problem --- This is where the configuration can become a little more complex. It helps to understand how Apache finds files to serve. Each host in Apache has a DocumentRoot. In Redhat Fedora, the line that defines that reads: DocumentRoot "/var/www/html" That means that when you enter the following URL: http://localhost/application/ Apache will look for the DirectoryIndex files (usually index.html) in: /var/www/html/application/ This is fine until you add an application server into the mix. Many people package up the entire application into one war file. This means that all static as well as dynamic content gets loaded into the application server area. In your case, that's /usr/local/tomcat/jakarta-tomcat-5.5.9/webapps Apache will know absolutely nothing about this directory, and any files that are not mapped by JkMount and served by Tomcat will not be found by Apache Static File Solutions - 1. Change DocumentRoot The most global change is to change DocumentRoot. In order for this to work, all files in /usr/local/tomcat/jakarta-tomcat-5.5.9/webapps must be readable by the user that runs Apache (typically apache in a Redhat distribution). The way to do this is to put the following as your DocumentRoot statement. DocumentRoot "/usr/local/tomcat/jakarta-tomcat/webapps" While this works, it means that you will have to place all web sites in this location, even if they do not have dynamic content. In general, I don't like this solution. 2. Add Directory and Alias Statements Traditionally locating static files in a dynamic web site has been done by using a combination of Directory and Alias directives. The Directory directive grants appropriate server permissions (who gets to see the files, etc.) and the Alias directive matches a directory with a base URL. For example, here's one way to map application1 living in /usr/local/tomcat/jakarta-tomcat/5.5.9/webapps/application1. # # This goes in httpd.conf # Options Indexes FollowSymlinks MultiViews AllowOverride None Order allow,deny Allow from all Alias /application1/ "/usr/local/tomcat/webapps/application1/" # # nice to block WEB-INF # AllowOverride None Order allow,deny Deny from all N
RE: Mod_jk + Apache on RHEL3 gives 503 for jsp only
To answer some questions below: Perfectly means it is our production tomcat server. It performs all the functions required and is accessed from the legacy webserver. Getting images from the path http://webserver/PI/image.png. We have no direct access linked to tomcat instances on the their ports. The Tomcat and Webserver will be on the same server. JkShmFile seems to be for unix installs where this resides on RedHat Linux EL3. I can add it if it is required for linux. Jkmount directives are not "new" but from a 4.1.24 Tomcat and Jk_mod that was upgraded. I will make the changes to be consistent with the deployed version of Tomcat. I have 4 workers setup. 1 points to a running 4.1.24 tomcat supporting an application to be replaced soon I hope. 1 to a separate port on the 4.12.24 tomcat server for one specific application because I was asked to set it up that way. 1 to the current production tomcat server. And one that is for testing and uses the same settings as the production but I can edit and change as I need to make things work. I am a bit frustrated as I have not done much to make things "break." I copied the config files and edited the httpd.conf to be consistent with the legacy install. This is the only part that does not work. "If Apache's DocumentRoot does not correspond to Tomcat's appBase, then any static files contained in the application will not be served by Apache without some more Apache configuration changes." Can you give me an example of this? -Original Message- From: Mark Eggers [mailto:[EMAIL PROTECTED] Sent: Thursday, October 06, 2005 10:54 PM To: Tomcat Users List Subject: Re: Mod_jk + Apache on RHEL3 gives 503 for jsp only --- "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I have jakarta-tomcat-5.5.9 installed and working > properly on the new > server. It is perfectly accessible from the legacy > web server. By perfectly accessible you mean . . . ? > The main page, home.jsp, loads fine in the servlet > if no page is given. > http://webserver/PI/ The home.jsp spawns a 503 if > is in the URL. > http://webserver/PI/home.jsp I can successfully > get images from the > page from the tomcat instance. It does not like the > .jsp extension. By successfully getting images, do you mean: http://webserver/PI/image.png or http://tomcatserver:8080/PI/image.png > I have watched in Ethereal as no traffic goes from > the apache to the > tomcat. > I have tried using the loopback and local network > address. Why? Is this Tomcat instance on the same server? > > #INSERT OF TOMCAT CONF PARAMETERS > # Load mod_jk module > # LoadModule jk_module modules/mod_jk.so > LoadModule jk_module /etc/httpd/modules/mod_jk.so > > # Declare the module for > #AddModule mod_jk.c > > # Where to find workers.properties > JkWorkersFile /etc/httpd/conf/workers.properties > > # Where to put jk logs > JkLogFile /var/log/httpd/mod_jk.log > > # Set the jk log level [debug/error/info] > JkLogLevel debug > > # Select the log format > JkLogStampFormat "[%a %b %d %H:%M:%S %Y] " > > # JkOptions indicate to send SSL KEY SIZE, > JkOptions +ForwardKeySize +ForwardURICompat > -ForwardDirectories > > # JkRequestLogFormat set the request format > JkRequestLogFormat "%w %V %T" > I don't see the specification for JkShmFile > # Send servlet for context /examples to worker named > worker1 > JkMount /examples/servlet/* worker1 The above should be: JkMount /servlets-examples/servlet/* worker1 > JkMount /PI/* worker3 > #JkMount /PI/*.jsp worker3 Why are you using worker3 here? > # Send JSPs for context /examples to worker named > worker1 > JkMount /examples/*.jsp worker1 The above shoould be /jsp-examples/*.jsp worker1 > JkMount /journals/*.jsp worker1 > > Worker Properties > /etc/httpd/conf/workers.properties > # Define some properties > workers.apache_log=/var/log/httpd/ > workers.tomcat_home=/usr/local/tomcat/jakarta-tomcat-5.5.9 > workers.java_home=/usr/bin/java > ps=/ > > # > worker.list=worker1 > According to the documentation this should contain a comma separated list of all the workers. However, if you're going to the same Tomcat instance all the time, you'll only need one worker definition > # Set properties for worker1 (ajp13) > worker.worker1.type=ajp13 > worker.worker1.host=172.20.1.19 > worker.worker1.port=8009 > First of all, there should only be one worker list. Second of all, why do you have multiple workers going to the same host but different ports? Do you have multiple Tomcats running on this host? > # > worker.list=worker2 > > # Set properties for worker2 (ajp13) > worker.worker2.type=ajp13 > worker.worker2.host=172.20.1.19 > worker.worker2
Re: Mod_jk + Apache on RHEL3 gives 503 for jsp only
--- "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I have jakarta-tomcat-5.5.9 installed and working > properly on the new > server. It is perfectly accessible from the legacy > web server. By perfectly accessible you mean . . . ? > The main page, home.jsp, loads fine in the servlet > if no page is given. > http://webserver/PI/ The home.jsp spawns a 503 if > is in the URL. > http://webserver/PI/home.jsp I can successfully > get images from the > page from the tomcat instance. It does not like the > .jsp extension. By successfully getting images, do you mean: http://webserver/PI/image.png or http://tomcatserver:8080/PI/image.png > I have watched in Ethereal as no traffic goes from > the apache to the > tomcat. > I have tried using the loopback and local network > address. Why? Is this Tomcat instance on the same server? > > #INSERT OF TOMCAT CONF PARAMETERS > # Load mod_jk module > # LoadModule jk_module modules/mod_jk.so > LoadModule jk_module /etc/httpd/modules/mod_jk.so > > # Declare the module for > #AddModule mod_jk.c > > # Where to find workers.properties > JkWorkersFile /etc/httpd/conf/workers.properties > > # Where to put jk logs > JkLogFile /var/log/httpd/mod_jk.log > > # Set the jk log level [debug/error/info] > JkLogLevel debug > > # Select the log format > JkLogStampFormat "[%a %b %d %H:%M:%S %Y] " > > # JkOptions indicate to send SSL KEY SIZE, > JkOptions +ForwardKeySize +ForwardURICompat > -ForwardDirectories > > # JkRequestLogFormat set the request format > JkRequestLogFormat "%w %V %T" > I don't see the specification for JkShmFile > # Send servlet for context /examples to worker named > worker1 > JkMount /examples/servlet/* worker1 The above should be: JkMount /servlets-examples/servlet/* worker1 > JkMount /PI/* worker3 > #JkMount /PI/*.jsp worker3 Why are you using worker3 here? > # Send JSPs for context /examples to worker named > worker1 > JkMount /examples/*.jsp worker1 The above shoould be /jsp-examples/*.jsp worker1 > JkMount /journals/*.jsp worker1 > > Worker Properties > /etc/httpd/conf/workers.properties > # Define some properties > workers.apache_log=/var/log/httpd/ > workers.tomcat_home=/usr/local/tomcat/jakarta-tomcat-5.5.9 > workers.java_home=/usr/bin/java > ps=/ > > # > worker.list=worker1 > According to the documentation this should contain a comma separated list of all the workers. However, if you're going to the same Tomcat instance all the time, you'll only need one worker definition > # Set properties for worker1 (ajp13) > worker.worker1.type=ajp13 > worker.worker1.host=172.20.1.19 > worker.worker1.port=8009 > First of all, there should only be one worker list. Second of all, why do you have multiple workers going to the same host but different ports? Do you have multiple Tomcats running on this host? > # > worker.list=worker2 > > # Set properties for worker2 (ajp13) > worker.worker2.type=ajp13 > worker.worker2.host=172.20.1.19 > worker.worker2.port=10009 > > # > worker.list=worker3 > > # Set properties for worker3 (ajp13) > worker.worker3.type=ajp13 > worker.worker3.host=127.0.0.1 > worker.worker3.port=8099 > > # > worker.list=worker4 > > # Set properties for worker4 (ajp13) > worker.worker4.type=ajp13 > worker.worker4.host=172.20.1.19 > worker.worker4.port=8099 Even after all that is done, there are some other issues when connecting Apache httpd and Tomcat. If Apache's DocumentRoot does not correspond to Tomcat's appBase, then any static files contained in the application will not be served by Apache without some more Apache configuration changes. There are several ways of accomplishing this, using the Directory directive and Aliases or JkAutoAlias in Apache's httpd.conf. /mde/ __ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]