You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Les Hazlewood <le...@hazlewood.com> on 2002/02/22 04:46:23 UTC

Very Complex Tomcat 4 / Apache / Virtual Host question

Hi all, 

I've read a TON of literature over the last 3 days, and I've found much of 
what I need to be lacking.... 

After reading full documentation on the jakarta website about how the 
server.xml is organized for tomcat 4, I still have some questions... 


I will first explain the desired setup, then I will show what I have. 

If you gracious folks can help me set this up, I will GLADLY set up a 
complete HOW-TO replicating the solution on my website for all the world to 
see.  Lord knows you probably get a lot of questions about this.  My hope is 
to guide the user by the hand step by step for this complex process.  I have 
been using Tomcat 3 for a long time with mod_jk and have been very happy, 
but I now need the newer features of Tomcat 4. 


Here's the setup (everywhere hereafter, I've replaced the actual domain 
names with <domainname> for privacy...just know that everytime you see that, 
its actually a domain name, and ignore the < > brackets :)) 

Redhat Linux 7.1
Apache 1.3.19
Java   JDK 1.4.0-rc
Tomcat 4.0.2  Light Edition (since I have jdk 1.4)
      installed in /usr/local/apache/jakarta/tomcat 

Virtual Host directories are located in:
      /www/www.<domainname>.com/
      /www/server.<domainname>.org/
      /www/etc, etc, 


Each domain name needs to run its own virtual machine, so I have set up the 
following variables:
$JAVA_HOME=/usr/local/java (where i have mine installed)
$CATALINA_HOME = /usr/local/apache/jakarta/tomcat 

for each virtual host, I have a directory:
/www/<domainname>.com/tomcat 

this directory has the following subdirs and files for EACH Virtual Host:
/www/<domainname>.com/tomcat/bin/startup.sh
/www/<domainname>.com/tomcat/bin/shutdown.sh
/www/<domainname>.com/conf/server.xml
/www/<domainname>.com/conf/tomcat-users.xml
/www/<domainname>.com/conf/web.xml
/www/<domainname>.com/conf/catalina.policy
/www/<domainname>.com/logs/
/www/<domainname>.com/webapps/
/www/<domainname>.com/work/ 

The startup.sh/shutdown.sh scrips set 
$CATALINA_BASE=/www/<domainname>.com/tomcat 

I don't know why I need a tomcat-users.xml file in the conf dir for virtual 
hosts, but if I don't include it, the tomcat instance for that virtual host 
won't start.  It starts if tomcat-users.xml is there. 

I have compiled mod_webapp.so directly from source and it now resides in 
apache's libexec directory...no problems there. 

In the httpd.conf file I have the following BEFORE the virtual hosts 
definitions: 

LoadModule webapp_module libexec/mod_webapp.so
AddModule mod_webapp.c 

Then for each virtual host (including the main server), I have in 
httpd.conf: 

<VirtualHost _default_>
   ServerName <domainname>.com
   ServerAlias www.<domainname>.com
   ServerAdmin <my email address here>
   .
   .   other vh junk here
   .
   WebAppConnection   conn1  warp  <domainname>.com:8011
   # note, 8011 corresponds to the warp connector in the virtual hosts's
   # server.xml located in /www/<domainname>.com/tomcat/conf/server.xml
   # Also, this is a different number per virtual host...i.e. 8011, 8013, 
etc
</VirtualHost> 


This is what happens after I start things up: 

Apache starts fine, with no error messages. 

I enter a virtual host directory, and start up it's tomcat instance via:
/www/<domainname>.com/tomcat/bin/startup.sh 

This instance starts up fine, and in
/www/<domainname>.com/tomcat/logs/catalina.out you see:
Starting service Apache-Tomcat-<domainname>.com
Apache Tomcat/4.0.2 

For a reason that I'll eplain later, this is the ONLY log file in this 
directory 

Everthing so far is good. 

Now, I go to the virtual host, in a web browser:
http://www.<domainname>.com/index.jsp 

the page shows up, but its all TEXT!!!  i.e. instead of being translated on 
the server side, and the generated page being output in html, it just shows 
everything, source code and all. 

Now, I look into /www/<domainname>.com/tomcat/logs directory again.  This 
time there is a file: 

apache_tomcat_<domainname>.com_log.2002-02-21.txt 

which i have defined earlier in server.xml.  The output is below.  The fact 
that the file is there now, and wasn't there before tells me Tomcat is doing 
something, but I don't know what, since the translated jsp's arent 
happening. 

I.E. when you look into /www/<domainname>.com/tomcat/work 

all you see is the following subdirectory structure:
www.<domainname>.com/_   but there is nothing in this "_" directory...nada, 
which basically mean's no servlets were generated by Tomcat. 

Here is the output from the newly generated log file: (the jar files are in 
the lib directory of the virtual hosts WEB-INF/lib structure) 

2002-02-21 21:32:36 WebappLoader[]: Deploying class repositories to work 
directory /www/<domainname>.com/tomcat/work/www.<domainname>.com/_
2002-02-21 21:32:36 WebappLoader[]: Deploy JAR /WEB-INF/lib/activation.jar 
to /winME/www/<domainname>.com/WEB-INF/lib/activation.jar
2002-02-21 21:32:36 WebappLoader[]: Deploy JAR 
/WEB-INF/lib/gnu.regexp-1.0.8.jar to 
/winME/www/<domainname>.com/WEB-INF/lib/gnu.regexp-1.0.8.jar
2002-02-21 21:32:36 WebappLoader[]: Deploy JAR /WEB-INF/lib/jdbc7.1-1.2.jar 
to /winME/www/<domainname>.com/WEB-INF/lib/jdbc7.1-1.2.jar
2002-02-21 21:32:36 WebappLoader[]: Deploy JAR /WEB-INF/lib/mail.jar to 
/winME/www/<domainname>.com/WEB-INF/lib/mail.jar
2002-02-21 21:32:36 WebappLoader[]: Deploy JAR /WEB-INF/lib/poolman.jar to 
/winME/www/<domainname>.com/WEB-INF/lib/poolman.jar
2002-02-21 21:32:36 WebappLoader[]: Deploy JAR /WEB-INF/lib/pop3.jar to 
/winME/www/<domainname>.com/WEB-INF/lib/pop3.jar
2002-02-21 21:32:36 WebappLoader[]: Deploy JAR /WEB-INF/lib/servlet.jar to 
/winME/www/<domainname>.com/WEB-INF/lib/servlet.jar
2002-02-21 21:32:36 WebappLoader[]: Reloading checks are enabled for this 
Context
2002-02-21 21:32:36 StandardManager[]: Seeding random number generator class 
java.security.SecureRandom
2002-02-21 21:32:37 StandardManager[]: Seeding of random number generator 
has been completed
2002-02-21 21:32:37 ContextConfig[]: Added certificates -> request attribute 
Valve
2002-02-21 21:32:38 StandardWrapper[:default]: Loading container servlet 
default2002-02-21 21:32:38 default: init
2002-02-21 21:32:38 StandardWrapper[:invoker]: Loading container servlet 
invoker2002-02-21 21:32:38 invoker: init
2002-02-21 21:32:38 jsp: init 


for your convenience, I have included the content of each virtual hosts' 
server.xml: 

<Server port="8010" shutdown="SHUTDOWN" debug="0"> 

 <Service name="Apache-Tomcat-<domainname>.com"> 

   <Connector className="org.apache.catalina.connector.warp.WarpConnector"
              port="8011"
              minProcessors="5"
              maxProcessors="75"
              enableLookups="true"
              acceptCount="10"
              debug="0"
              connectionTimeout="60000"/>

   <Engine name="Apache-Tomcat-<domainname>.com"
           defaultHost="www.<domainname>.com" debug="0"> 

     <!-- Global logger unless overridden at lower levels -->
     <Logger className="org.apache.catalina.logger.FileLogger"
             prefix="apache_tomcat_<domainname>.com_log."
             suffix=".txt"
             timestamp="true"/> 

     <!-- Define the default virtual host -->
     <Host name="www.<domainname>.com"
           debug="0"
	    appBase="/www/<domainname>.com/"
           unpackWARs="true">

        <Alias><domainname>.com</Alias> 

        <Context path=""
                 docBase="/www/<domainname>.com"
		  reloadable="true"
		  debug="0"/>

     </Host> 

     <Realm className="org.apache.catalina.realm.MemoryRealm" /> 

   </Engine> 

 </Service> 

</Server> 

 

If you guys help, I'll post a fully detailed HOW-TO that everyone can refer 
to!!! (or better yet, I can just give it to the jakarta admin people and 
they can post it). 

 

PUHLEASE help :) 


Thanks, 

Les Hazlewood 


 --
Tigger says, "Share Bandwidth!"

--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


Re: Very Complex Tomcat 4 / Apache / Virtual Host question

Posted by chad kellerman <ck...@alabanza.com>.
Les,

    This part of Tomcat is a pain.  Actaully I am working on the same thing.  Different directory structure but I want the same outcome.  I am not saying what I have done is right but it works.  At least so far.  It has only been running for a couple days with one vitual host, besides the actual host box name.


Red Hat 6.2 webapp module and tomcat 4.0.1

First the httpd.conf.  My directiry structure is different but just change it.

###Tomcat installation
LoadModule webapp_module libexec/mod_webapp.so
WebAppConnection warpConnection warp jakarta.$hostboxservername.com:8008
###


THis section has to go below where you have the ServerName of the Host box declared.  Or you get a bad host name error on apachectl configtest.

Next the Virtual Host.

<VirtualHost jakarta.domain.net>
User jak
Group jakartagrp
ServerName jakarta.gotc.net
ServerAdmin webmaster@jakarta.domain.net
DocumentRoot /home/jak/jakarta-www
TransferLog /home/jak/jakarta-logs/access-log
ScriptAlias /cgi-bin/ /home/jak/jakarta-www/cgi-bin/
WebAppConnection apoWarpConn warp jakarta.domain.net:8015
WebAppDeploy webapps  apoWarpConn    /webapps/ 
WebAppDeploy  manager apoWarpConn     /manager/
WebAppDeploy examples warpConnection /examples/
</VirtualHost>

Once again all webapp module directives need to go after the ServerName.  I copied the examples from {TOMCAT_HOME}/webapps/examples to the Document root of the Virtual Host just to see if the damn things work.


  I have not touche the tomcat-users.xml or the web.xml in the {TOMCAT_HOME}/conf directory yet.  I am still going to do some testing on this configuration.  Plus I want to see if anyone have any feed back on how I can improve it.

Next is the server.xml configuration file.  I want all the log files for tomcat to go to my logs directory that I set in the Virtual Host section above.

Here is what I did to the server.xml file.
FIrst I changed The engine container.  I read in the tomcat3.2 docs that standalone is not the best performing engine, eventhough it is the default. ( I think its a java thing. :^)  So I changed it to In-process.  After I get everything configured I am going to test Out-of-process also.  But that is later.

<!-- Define the top level container in our container hierarchy -->
    <Engine name="In-process" defaultHost="jakarta.$hostbox.com" debug="0">

Don't be confused with 

<!-- Define the Tomcat Stand-Alone Service -->
  <Service name="Tomcat-Standalone">

I left that alone.


Then I changed 

<!-- Define the default virtual host -->
<Host name="jakarta.$hostbox.com"debug="0"appBase="/home/httpd/html/webapps" unpackWARs="true">

  I know localhost was supposed to be here, but whenever I tested the mail servlet, it acted "wierd".  But this way everything works good.


  Here it where I added the Virtual Host:


   <!-- Test Host element section -->

<Host name="jakarta.virtualhost.net" debug="0" appBase="/home/jak/jakarta-www/" unpackWARS="false">

        <!-- Access log directive
        -->
        <Valve className="org.apache.catalina.valves.AccessLogValve"
                directory="/home/jak/jakarta-logs" prefix="tomcat-access-logs" suffix=".txt" pattern="common" />

        <!-- Context log directive.  Can be commented out.
        -->
        <Logger className="org.apache.catalina.logger.FileLogger"
                directory="/home/jak/jakarta-logs" prefix="tomcat-logs." suffix=".txt" timestamp="true"/>
        
        <!-- Additional Context directives.  Adds funtionality to appBase
        -->
        <!-- Tomcat Manager Context -->
        <Context path="/home/jak/jakarta-www/manager" docBase="manager"
        debug="0" privileged="true"/>

        <!-- Tomcat Examples Context and Logging info -->
        <Context path="/home/jak/jakarta-www/examples" docBase="/home/jak/jakarta-www/webapps/examples" debug="0" reloadable="true"/>
                <Logger className="org.apache.catalina.logger.FileLogger"
                        directory="/home/jak/jakarta-logs" prefix="examples-logs." suffix=".txt" timestamp="true"/>
</Host>


  I put this whole section after the host section for the server and before the 


</Engine>

  </Service>

lines.


    I still have to look into a few things.  My access logs for tomcat are not writing properly but everything else works.


   Now here is the most importatn part.  Make sure tomcat and apache are not running.  Start tomcat first then apache, or it will not work.

That is what I have so far.  I might not be pretty or even right but it works.  Please it anyone has any suggestions let me, us, know.

Thanks

-chad






 
On Thu, 21 Feb 2002 22:46:23 -0500
"Les Hazlewood" <le...@hazlewood.com> wrote:

> 
> Hi all, 
> 
> I've read a TON of literature over the last 3 days, and I've found much of 
> what I need to be lacking.... 
> 
> After reading full documentation on the jakarta website about how the 
> server.xml is organized for tomcat 4, I still have some questions... 
> 
> 
> I will first explain the desired setup, then I will show what I have. 
> 
> If you gracious folks can help me set this up, I will GLADLY set up a 
> complete HOW-TO replicating the solution on my website for all the world to 
> see.  Lord knows you probably get a lot of questions about this.  My hope is 
> to guide the user by the hand step by step for this complex process.  I have 
> been using Tomcat 3 for a long time with mod_jk and have been very happy, 
> but I now need the newer features of Tomcat 4. 
> 
> 
> Here's the setup (everywhere hereafter, I've replaced the actual domain 
> names with <domainname> for privacy...just know that everytime you see that, 
> its actually a domain name, and ignore the < > brackets :)) 
> 
> Redhat Linux 7.1
> Apache 1.3.19
> Java   JDK 1.4.0-rc
> Tomcat 4.0.2  Light Edition (since I have jdk 1.4)
>       installed in /usr/local/apache/jakarta/tomcat 
> 
> Virtual Host directories are located in:
>       /www/www.<domainname>.com/
>       /www/server.<domainname>.org/
>       /www/etc, etc, 
> 
> 
> Each domain name needs to run its own virtual machine, so I have set up the 
> following variables:
> $JAVA_HOME=/usr/local/java (where i have mine installed)
> $CATALINA_HOME = /usr/local/apache/jakarta/tomcat 
> 
> for each virtual host, I have a directory:
> /www/<domainname>.com/tomcat 
> 
> this directory has the following subdirs and files for EACH Virtual Host:
> /www/<domainname>.com/tomcat/bin/startup.sh
> /www/<domainname>.com/tomcat/bin/shutdown.sh
> /www/<domainname>.com/conf/server.xml
> /www/<domainname>.com/conf/tomcat-users.xml
> /www/<domainname>.com/conf/web.xml
> /www/<domainname>.com/conf/catalina.policy
> /www/<domainname>.com/logs/
> /www/<domainname>.com/webapps/
> /www/<domainname>.com/work/ 
> 
> The startup.sh/shutdown.sh scrips set 
> $CATALINA_BASE=/www/<domainname>.com/tomcat 
> 
> I don't know why I need a tomcat-users.xml file in the conf dir for virtual 
> hosts, but if I don't include it, the tomcat instance for that virtual host 
> won't start.  It starts if tomcat-users.xml is there. 
> 
> I have compiled mod_webapp.so directly from source and it now resides in 
> apache's libexec directory...no problems there. 
> 
> In the httpd.conf file I have the following BEFORE the virtual hosts 
> definitions: 
> 
> LoadModule webapp_module libexec/mod_webapp.so
> AddModule mod_webapp.c 
> 
> Then for each virtual host (including the main server), I have in 
> httpd.conf: 
> 
> <VirtualHost _default_>
>    ServerName <domainname>.com
>    ServerAlias www.<domainname>.com
>    ServerAdmin <my email address here>
>    .
>    .   other vh junk here
>    .
>    WebAppConnection   conn1  warp  <domainname>.com:8011
>    # note, 8011 corresponds to the warp connector in the virtual hosts's
>    # server.xml located in /www/<domainname>.com/tomcat/conf/server.xml
>    # Also, this is a different number per virtual host...i.e. 8011, 8013, 
> etc
> </VirtualHost> 
> 
> 
> This is what happens after I start things up: 
> 
> Apache starts fine, with no error messages. 
> 
> I enter a virtual host directory, and start up it's tomcat instance via:
> /www/<domainname>.com/tomcat/bin/startup.sh 
> 
> This instance starts up fine, and in
> /www/<domainname>.com/tomcat/logs/catalina.out you see:
> Starting service Apache-Tomcat-<domainname>.com
> Apache Tomcat/4.0.2 
> 
> For a reason that I'll eplain later, this is the ONLY log file in this 
> directory 
> 
> Everthing so far is good. 
> 
> Now, I go to the virtual host, in a web browser:
> http://www.<domainname>.com/index.jsp 
> 
> the page shows up, but its all TEXT!!!  i.e. instead of being translated on 
> the server side, and the generated page being output in html, it just shows 
> everything, source code and all. 
> 
> Now, I look into /www/<domainname>.com/tomcat/logs directory again.  This 
> time there is a file: 
> 
> apache_tomcat_<domainname>.com_log.2002-02-21.txt 
> 
> which i have defined earlier in server.xml.  The output is below.  The fact 
> that the file is there now, and wasn't there before tells me Tomcat is doing 
> something, but I don't know what, since the translated jsp's arent 
> happening. 
> 
> I.E. when you look into /www/<domainname>.com/tomcat/work 
> 
> all you see is the following subdirectory structure:
> www.<domainname>.com/_   but there is nothing in this "_" directory...nada, 
> which basically mean's no servlets were generated by Tomcat. 
> 
> Here is the output from the newly generated log file: (the jar files are in 
> the lib directory of the virtual hosts WEB-INF/lib structure) 
> 
> 2002-02-21 21:32:36 WebappLoader[]: Deploying class repositories to work 
> directory /www/<domainname>.com/tomcat/work/www.<domainname>.com/_
> 2002-02-21 21:32:36 WebappLoader[]: Deploy JAR /WEB-INF/lib/activation.jar 
> to /winME/www/<domainname>.com/WEB-INF/lib/activation.jar
> 2002-02-21 21:32:36 WebappLoader[]: Deploy JAR 
> /WEB-INF/lib/gnu.regexp-1.0.8.jar to 
> /winME/www/<domainname>.com/WEB-INF/lib/gnu.regexp-1.0.8.jar
> 2002-02-21 21:32:36 WebappLoader[]: Deploy JAR /WEB-INF/lib/jdbc7.1-1.2.jar 
> to /winME/www/<domainname>.com/WEB-INF/lib/jdbc7.1-1.2.jar
> 2002-02-21 21:32:36 WebappLoader[]: Deploy JAR /WEB-INF/lib/mail.jar to 
> /winME/www/<domainname>.com/WEB-INF/lib/mail.jar
> 2002-02-21 21:32:36 WebappLoader[]: Deploy JAR /WEB-INF/lib/poolman.jar to 
> /winME/www/<domainname>.com/WEB-INF/lib/poolman.jar
> 2002-02-21 21:32:36 WebappLoader[]: Deploy JAR /WEB-INF/lib/pop3.jar to 
> /winME/www/<domainname>.com/WEB-INF/lib/pop3.jar
> 2002-02-21 21:32:36 WebappLoader[]: Deploy JAR /WEB-INF/lib/servlet.jar to 
> /winME/www/<domainname>.com/WEB-INF/lib/servlet.jar
> 2002-02-21 21:32:36 WebappLoader[]: Reloading checks are enabled for this 
> Context
> 2002-02-21 21:32:36 StandardManager[]: Seeding random number generator class 
> java.security.SecureRandom
> 2002-02-21 21:32:37 StandardManager[]: Seeding of random number generator 
> has been completed
> 2002-02-21 21:32:37 ContextConfig[]: Added certificates -> request attribute 
> Valve
> 2002-02-21 21:32:38 StandardWrapper[:default]: Loading container servlet 
> default2002-02-21 21:32:38 default: init
> 2002-02-21 21:32:38 StandardWrapper[:invoker]: Loading container servlet 
> invoker2002-02-21 21:32:38 invoker: init
> 2002-02-21 21:32:38 jsp: init 
> 
> 
> for your convenience, I have included the content of each virtual hosts' 
> server.xml: 
> 
> <Server port="8010" shutdown="SHUTDOWN" debug="0"> 
> 
>  <Service name="Apache-Tomcat-<domainname>.com"> 
> 
>    <Connector className="org.apache.catalina.connector.warp.WarpConnector"
>               port="8011"
>               minProcessors="5"
>               maxProcessors="75"
>               enableLookups="true"
>               acceptCount="10"
>               debug="0"
>               connectionTimeout="60000"/>
> 
>    <Engine name="Apache-Tomcat-<domainname>.com"
>            defaultHost="www.<domainname>.com" debug="0"> 
> 
>      <!-- Global logger unless overridden at lower levels -->
>      <Logger className="org.apache.catalina.logger.FileLogger"
>              prefix="apache_tomcat_<domainname>.com_log."
>              suffix=".txt"
>              timestamp="true"/> 
> 
>      <!-- Define the default virtual host -->
>      <Host name="www.<domainname>.com"
>            debug="0"
> 	    appBase="/www/<domainname>.com/"
>            unpackWARs="true">
> 
>         <Alias><domainname>.com</Alias> 
> 
>         <Context path=""
>                  docBase="/www/<domainname>.com"
> 		  reloadable="true"
> 		  debug="0"/>
> 
>      </Host> 
> 
>      <Realm className="org.apache.catalina.realm.MemoryRealm" /> 
> 
>    </Engine> 
> 
>  </Service> 
> 
> </Server> 
> 
>  
> 
> If you guys help, I'll post a fully detailed HOW-TO that everyone can refer 
> to!!! (or better yet, I can just give it to the jakarta admin people and 
> they can post it). 
> 
>  
> 
> PUHLEASE help :) 
> 
> 
> Thanks, 
> 
> Les Hazlewood 
> 
> 
>  --
> Tigger says, "Share Bandwidth!"
> 
> --
> To unsubscribe:   <ma...@jakarta.apache.org>
> For additional commands: <ma...@jakarta.apache.org>
> Troubles with the list: <ma...@jakarta.apache.org>
> 

--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>