----- Original Message -----

> From: r.sriram <sri...@rstech.net>
> To: Tomcat Users List <users@tomcat.apache.org>
> Cc: 
> Sent: Wednesday, December 21, 2011 5:27 PM
> Subject: Re: Hosted environment
> 
> you sound quite obnoxious and you don't seem to have any valid answers 
> other than insulting others.
> I need my virtual host to work. I need to configure Tomcat to make it 
> work. Mark provided specific steps and I followed it, but it didn't 
> work. I need specifically why it didn't work.
> do you have any suggestions, or you can let others answer.
> and bottom-posting annoys me.
> 
> On 12/21/2011 11:19 PM, Pid wrote:
>>  On 21/12/2011 17:38, r.sriram wrote:
>>>  is it possible for you to give me steps on what I should do please to
>>>  make the virtual host work.
>>>  I have domain name x.com, y.com and z.com  (for example). For this what
>>>  should the setup be so www.x.com, www.y.com and www.z.com take me to 
> the
>>>  servlet appropriate for each?
>>  Please, *please*, stop top-posting.  It's lazy, it makes it harder for
>>  people to follow the conversation and it annoys me.
>> 
>>  What are you not clear about?
>>  Ask specific questions and we will provide specific answers.
>> 
>> 
>>  p
>> 
>> 
>>> 
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>>> 
>>> 
>>> 
>>>  On 12/21/2011 10:09 PM, Pid wrote:
>>>>  On 20/12/2011 11:55, Pid wrote:
>>>>>  On 20/12/2011 09:21, r.sriram wrote:
>>>>>>  Thanks Andre.
>>>>>>  a few quick questions.
>>>>>> 
>>>>>>  Questions with respect to your response:
>>>>>>  Your response:
>>>>>> 
>>>>>>       <Host name="host1.domain1.com"... 
> appBase="/path1/webapps/" ..>
>>>>>>       ...
>>>>>>       </Host>
>>>>>> 
>>>>>>       <Host name="host2.domain2.com"... 
> appBase="/path2/webapps/" ..>
>>>>>>       ...
>>>>>>       </Host>
>>>>>> 
>>>>>>  Questions:
>>>>>> 
>>>>>>     * which is the file where I should add these lines
>>>>>     tomcat/conf/server.xml
>>>>> 
>>>>>>     * Is host1:www. If not what is it?
>>>>>  I don't know what that means.
>>>>> 
>>>>>>     * does path1, path2 etc. start at CATALINA_HOME?
>>>>>  See below.
>>>>> 
>>>>>>     * Is there any other configuration change that I need to 
> do
>>>>>  Yes, you will need to configure the connection between HTTPD 
> and Tomcat,
>>>>>  using mod_proxy or mod_jk.
>>>>> 
>>>>>>  My Situation
>>>>>>  Tomcat will be installed in directory let us say in Program 
> Files (*86)
>>>>>>  directory. That will have the web-inf directory.
>>>>>  WEB-INF, not web-inf.
>>>>> 
>>>>>>  Each domain has its own root, let us say: 
> ..\domainX.com\httpdocs,
>>>>>>  domainY.com\httpdocs etc.
>>>>>  In that case, there should also be:
>>>>> 
>>>>>     ..\domainX.com\appBase
>>>>>     ..\domainY.com\appBase
>>>>  Like I said here ^^^
>>>> 
>>>> 
>>>>>>  Questions:
>>>>>> 
>>>>>>     * should I copy WEB-INF directory from C:\Program 
> Files
>>>>>>       
> (x86)\apache-tomcat-6.0.33\webapps\ROOT\ to each of
>>>>>>       ..\domainX.com\httpdocs, 
> domainY.com\httpdocs etc.
>>>>>  No. Definitely not.
>>>>> 
>>>>>  A web application is not the same as a document root.
>>>>> 
>>>>>  You should move the whole of ROOT to the appBase described 
> above.
>>>>  and here ^^^
>>>> 
>>>> 
>>>>  p
>>>> 
>>>> 
>>>>>>  On 12/19/2011 1:12 PM, André Warnier wrote:
>>>>>>>  r.sriram wrote:
>>>>>>>>  Hello,
>>>>>>>>  I am setting up my multiple domains on Go Daddy. In 
> my current
>>>>>>>>  in-house windows server my Tomcat is on Program 
> Files (86) and the
>>>>>>>>  ROOT is in C:\Program Files 
> (x86)\apache-tomcat-6.0.33\webapps
>>>>>>>>  directory. That is where WEB-INF is, that is what 
> is my actual path
>>>>>>>>  for all files that gets picked up by my web pages 
> (including my
>>>>>>>>  servlets).
>>>>>>>> 
>>>>>>>>  In Go Daddy, there would be different ROOTs for 
> each domain.
>>>>>>>>  (../<domain>/httpdocs) But there would be one 
> Tomcat installation.
>>>>>>>> 
>>>>>>>>  can Tomcat be installed in Program Files (86), and 
> the servlets, and
>>>>>>>>  all the files needed for the domain be placed in 
> ../<domain
>>>>>>>>  name>/httpdocs?
>>>>>>>>  Thanks.....Ram
>>>>>>>> 
>>>>>>>  Sure. Look at virtual hosts, here :
>>>>>>> 
> http://tomcat.apache.org/tomcat-7.0-doc/config/host.html
>>>>>>>  (and their appBase attribute)
>>>>>>> 
>>>>>>>  <Host name="host1.domain1.com"... 
> appBase="/path1/webapps/" ..>
>>>>>>>  ...
>>>>>>>  </Host>
>>>>>>> 
>>>>>>>  <Host name="host2.domain2.com"... 
> appBase="/path2/webapps/" ..>
>>>>>>>  ...
>>>>>>>  </Host>
>>>>>>>  etc..
>>>>>>> 
>>>>>>>  I suggest to leave the default<Host 
> name="localhost" ..>   as it is,
>>>>>>>  and just add the others.
>>>>>>> 
>>>>>>> 


Hmm, it certainly does work. I currently have about 100 virtual hosts, 8 
CATALINA_BASE implementations, and SSL with a SAN Cert. I just finished setting 
up another instance (took about 15 minutes) to do some application testing.

It's the setup I use because it cleanly decouples everything (Apache HTTPD 
configurations, pristine CATALINA_HOME, default Tomcat applications for 
connectivity / service testing, and an easy upgrade path). I'm toying around 
with a script that will automate the entire installation, but I've not reached 
that pain point yet.

Briefly:

In Apache HTTPD you need to do this:

1. Create a directory for each DocumentRoot - maybe C:\HTTPD\hosts\x.com
2. Create a named virtual host for each of the virtual hosts.
   Something like the following:


#
# note that I've left out all of the mod_jk configuration
# Please read the documentation
#

NameVirtualHost *:80

#
# Repeat for additional named virtual hosts
#
<VirtualHost *:80>
    ServerAdmin your-em...@address.come
    DocumentRoot C:/HTTPD/hosts/x.com
    ServerName www.x.com
    #
    # Aliases as necessary
    #
    ServerAlias x.com
    #
    # Define your logging as you wish - this is just an example
    #
    ErrorLog logs/x.com-error_log
    CustomLog logs/x.com-access_log common
</VirtualHost>

3. In each named virtual host add a reference to a mount file.
   There are lots of other ways to map stuff, this is one
   Read the documentation

Now the named virtual host looks like this:
<VirtualHost *:80>
    ServerAdmin your-em...@address.com
    DocumentRoot C:/HTTPD/hosts/x.com
    ServerName www.x.com
    #
    # Aliases as necessary
    #
    ServerAlias x.com
    #
    # Define your logging as you wish - this is just an example
    #
    ErrorLog logs/x.com-error_log
    CustomLog logs/x.com-access_log common
    #
    # One of many ways to map resources to Tomcat - read the docs
    # If your Apache HTTPD is in C:\Apache\Apache2.2\
    # Or you can place it outside of the Apache directory tree - recommended
    #
    JkMountFile C:/Apache/Apache2.2/conf/extra/x.com.uriworkermap.properties
</VirtualHost>

4. In x.com.uriworkermap.properties

#
# Map stuff
# Add excludes if you place material where Apache HTTPD can directly serve them
# This will map everything
#
JkMount /=xcom
JkMount /*=xcom

5. In workers.properties

#
# This is very minimal
# Read the docs
# port must match server.xml port for AJP connector
#
worker.list=xcom

worker.xcom.type=ajp13
worker.xcom.host=localhost
worker.xcom.port=8009

In Tomcat, do the following

1. Make a directory for your virtual host - maybe C:\AJP\x.com\webapps

2. Leave the default host alone

3. Make a name attribute of a Host element matches a named virtual host 
ServerName

<Host name="www.x.com"
      appBase="C:/AJP/x.com/webapps"
      autoDeploy="true"
      unpackWARs="true">
      <!-- add aliases if needed - match ServerAlias from httpd.conf -->
</Host>

4. Make sure your AJP Connector is set up properly to match workers.properties

<!-- something like the following - read the documentation -->
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443"
               URIEncoding="UTF-8"/>

All will work together happily.

I've left out a lot. Here are things you need to read.

1. Apache HTTPD configuration for mod_jk (the AJP connector)
2. Apache HTTPD configuration for named virtual hosts
3. Tomcat connector configuration (lots of examples in the source code as well)
4. Tomcat documentation - virtual hosts and AJP connector configuration

If you want to serve static files with Apache HTTPD and the rest with Tomcat, 
you'll need to do something like the following.

If you're using Maven, build your project with mvn package, and then go to the
<project-name>/target directory.

You'll see both the WAR file and a directory <project-name> containing the 
exploded web application. Just tar or zip the exploded web application and 
include only those files you wish to include - I'm guessing *.css, *.html, 
*.js, *.jpg, etc.

Explode that tar or zip file in C:/HTTPD/hosts/x.com with the same directory 
structure as your application. If it's the ROOT application, then explode the 
tar or zip file in C:/HTTPD/hosts/x.com (for example).

Now, use JkUnmount directives in x.com.uriworkermap.properties to not send this 
off to Tomcat.

If you use NetBeans, then the exploded web application is in 
<project-name>/build/web.

. . . . just my two cents.
/mde/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to