tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier>
Subject Re: LAMP + Tomcat Configuration
Date Sun, 11 Dec 2011 23:07:23 GMT
Truckman wrote:
> Greetings,
> I apologize for the length/complexity of this but I've learned over the
> years providing more detail generally saves time of those who are kind
> enough to assist.
> I have a slew of "standard" webservers which run the usual LAMP model -
> CentOS6, Apache 2.2.15-5, MySQL 5.0.77-4, and PHP 5.3.2-6.  I host many
> virtual domains and each virtual server runs off a unique directory, roughly
> matching the assigned domain name, like so:
> translates to /var/www/html.forums
> No problems whatsoever, except now one of those virtual domains requires
> Tomcat6, and I'm trying to figure out how to integrate Tomcat6 for one
> virtual domain only.  This way, all the other domains I host can remain
> "as-is" in their working state.
> Using Yum, I installed Tomcat6 and the various auxiliary RPMs:
> apache-tomcat-apis-0.1-1.el6.noarch
> jakarta-commons-dbcp-tomcat5-1.2.1-13.8.el6.noarch
> jakarta-commons-pool-tomcat5-1.3-12.7.el6.x86_64
> tomcat6-6.0.24-24.el6_0.noarch
> tomcat6-admin-webapps-6.0.24-24.el6_0.noarch
> tomcat6-docs-webapp-6.0.24-24.el6_0.noarch
> tomcat6-el-2.1-api-6.0.24-24.el6_0.noarch
> tomcat6-javadoc-6.0.24-24.el6_0.noarch
> tomcat6-jsp-2.1-api-6.0.24-24.el6_0.noarch
> tomcat6-lib-6.0.24-24.el6_0.noarch
> tomcat6-log4j-6.0.24-24.el6_0.noarch
> tomcat6-servlet-2.5-api-6.0.24-24.el6_0.noarch
> tomcat6-webapps-6.0.24-24.el6_0.noarch
> I started Tomcat6, added it to chkconfig so it automatically starts, and as
> I expected Tomcat6 answers on port 8009 (ajp) and port 8080 (tomcat).
> The customer then passed me a forums.war file, stating it needs to be in the
> root directory of the virtual server, so I placed it in the
> /var/www/html.forums directory.
> Knowing that apache is answering port 80, and that needs to be forwarded
> "up" to port 8080, I made the following changes in the virtual server
> configuration, like so:
> <VirtualHost  *:80>
>         Servername
>         DocumentRoot    /var/www/html.forums
>         <Directory />
>           Options FollowSymLinks
>           AllowOverride All
>           Order allow,deny
>           Allow from all
>           ProxyPass ajp://localhost:8009/
>         </Directory>
> </VirtualHost>
> Now, when I hit, I get the expected Tomcat6
> welcome page, but cannot be found.  I'm
> assuming that's because forums.war is located in the virtual directory in
> "regular apache" and not where "tomcat apache" is expecting it.
> I am really confused as what I should be doing next, or even if what I've
> done so far was "correct".
> The goal is to have "regular" apache answer port 80, and call upon "tomcat"
> on port 8080 (or 8009 ajp) as required by the web application stored in
> "regular" apache's virtual server directory for that domain.
Thank you for your nice and thorough explanation above, which makes a nice break from the

"I want to use Tomcat to connect to my CFDTY web service. Tell me asap and in detail how 
to do it" kind of request.

Since you appear to be a real newbie with Tomcat (sorry if I'm wrong there), I have tried

to write the following for someone who does not know Tomcat at all, but knows Apache httpd

well.  I am thus trying to give you an overview, and some elementary pointers which may 
help you understand the excellent and extensive on-line documentation of Tomcat, available

This will take just a few minutes to read, and will probably save you (and others on this

list) a couple of hours of talking at cross-purposes.

Tomcat is a Java Servlet Engine first, and a webserver second.
As a java servlet engine, its *primary* function is to provide an environment suitable to

run java servlets. Java servlets in turn are small (or less small) pieces of java code, 
which are usually grouped in a collection called a "web application", or "webapp".
So a "webapp" is a collection of such java servlets (programs) and of pure html pages 
(and/or of html pages containing a mixture of html and java code), the whole collection 
being designed generally to achieve something useful in a WWW context.

To make a parallel at this point with Apache httpd (with which you seem more familiar) :
Imagine that you have an Apache-httpd VirtualHost, with a DocumentRoot in 
/srv/www/myhost1/docs, and underneath that DocumentRoot you have a sub-directory 
/srv/www/myhost1/docs/accounting/ which contains the html pages and php scripts etc.. 
which together constitute .. an accounting application.
In Tomcat, this sub-directory and all the files in it would be called "the accounting webapp".

One difference between Tomcat and Apache-httpd, is that under Tomcat you can install such

an application in different ways :
- you can, as with Apache-httpd, just copy all the files that make up the webapp, in the 
sub-directory "accounting" of the Tomcat "DocumentRoot" (which under Tomcat is called the

- or you can zip all these files together into one single file named "accounting.war", and

just drop that single file in the Tomcat appBase. And Tomcat (with the appropriate setup),

will automatically create the "accounting" subdirectory and unzip that .war file into all

the constituents of the accounting webapp, inside that sub-directory.
(That, by the way, was an explanation of what a "war-file" is : it stands for Web 
Application Archive, and it is just a zip file).

So, once you have dropped that .war file under the Tomcat appBase, you never refer to it 
again (at least, not in URLs). It has been unzipped, and the application has been 
"deployed" (into all its constituent files), and Tomcat also automatically starts the 
And if you want to update the accounting application (even with Tomcat running), you just

drop another version of that accounting.war file in the same place, and Tomcat will
- stop the old application
- delete it
- expand the new accounting.war file in the "accounting" sub-directory again
- and restart the application
Neat, he ?  Apache-httpd does not really let you do this on-the-fly.

Another difference is the following :
- under Apache-httpd, the DocumentRoot is, for example, /srv/www/myhost1/docs/. So 
anything that you put directly under there (for example, a file named "some_page.html), 
can be called up by the URL http://myhost1/some_page.html.
- under Tomcat however, you never put something directly under the appBase (which is 
usually a directory like /var/lib/tomcat/webapps/). Instead, if you want a document to be

called by a URL like http://myhost1:8080/some_page.html, you put it under a sub-directory

"/ROOT/" of the appBase (e.g. as /var/lib/tomcat/webapps/ROOT/some_page.html)

Alomost finally : the way in which Tomcat "maps" a request URL to a web application is 
similar, but not quite the same, as how Apache-httpd maps a URL to a sub-directory of the

In Tomcat, there is a notion of a "default application" : if Tomcat tries to map a URL to

a webapp (which it does much in the same way as Apache-httpd), but fails to do so, then 
Tomcat will "send" the request to the default application, which is ..  the one which is 
under webapps/ROOT/ (supposing that there is one). (And for example, that's how you got 
the Tomcat welcome page).

So now, you can go to, and start reading further.

In parallel, find some empty directory on your workstation, take that ".war" file which 
your customer gave you, and use the unzip function to expand it.
That will show you what files are in there, and give you an idea of the internal structure

of a webapp.

And still one more thing : you have chosen to install Tomcat using a pre-packaged CenTOS 
version of Tomcat, and this can make things a bit more complicated for the people here 
trying to help you, in the following sense :

The "standard Tomcat" which you can download from the Tomcat website, unpacks in a simple standard directory hierarchy which looks 
like this :
(top-install-directory, e.g. /usr/local/tomcat7/), with sub-directories
    - bin : the executables
    - conf : the configuration files
    - common : common library files
    - webapps : the applications (webapps) (of which ROOT)
    - log : the logfiles
    - work : place for temporary files
So with a distribution like that one, it is easy because we can tell you exactly where to

look, and where to place things (like your .war file).

With the pre-packaged Linux versions, things are different.  For a whole series of good 
reasons to do with package management, these packages tend to distribute the Tomcat 
directories and files all over the place, and put this all back together using a profusion

of symlinks.  So it can be a challenge finding exactly where all the files are.
You will probably find the "top tomcat directory" as /usr/share/tomcat or /var/lib/tomcat,

and from there be led through a series of links to places like
   - /etc/tomcat --> /var/lib/tomcat/conf
   - /var/log/tomcat (the logfiles)
   - /var/lib/tomcat/conf (which is also linked to by /etc/tomcat)
   - /var/lib/tomcat/webapps
   - /var/lib/tomcat/work --> /var/cache/tomcat
So, try to locate these directories on your server, write them down, and then we can start

helping you with your particular issue.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message