aspose file tools*
The moose likes Tomcat and the fly likes Two sites with Tomcat 6 and Apache 2.2 (Problem) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Two sites with Tomcat 6 and Apache 2.2 (Problem)" Watch "Two sites with Tomcat 6 and Apache 2.2 (Problem)" New topic
Author

Two sites with Tomcat 6 and Apache 2.2 (Problem)

Karl Larsson
Greenhorn

Joined: Apr 12, 2012
Posts: 3
Maybe this is the wrong forum. If so I apologies but I don't know of a better one.

I want to have two sites (www.foo1.com, www.foo2.com) running on the same Ubuntu desktop (12.04). My setup works only half way, www.fooX.com shows Tomcats deafault "It works!"-page. What have I missed???

In this example I try to access the sites from my local Firefox and use /etc/hosts för name server. My desktop have a static IP (192.168.1.3).

* Add two rows to /etc/hosts
$ sudo gedit /etc/hosts


* Add two directories for the two sites JSP files
$ sudo mkdir /db
$ sudo mkdir /db/foo1
$ sudo mkdir /db/foo2

* Create the some example JSP files
$ sudo gedit /db/foo1/index.jsp


$ sudo gedit /db/foo2/index.jsp


* /etc/tomcat6/server.xml
* Uncomment this row:
$ sudo gedit /etc/tomcat6/server.xml


* Put the following rows between <Engine>...</Engine>, for example below <Host name="localhost" ...>...</Host>
$ sudo gedit /etc/tomcat6/server.xml


* Tomcat config files for each site
$ sudo mkdir /etc/tomcat6/Catalina/foo1.com
$ sudo mkdir /etc/tomcat6/Catalina/foo2.com
$ sudo gedit /etc/tomcat6/Catalina/foo1.com/ROOT.xml


$ sudo gedit /etc/tomcat6/Catalina/foo2.com/ROOT.xml


* Apache config files for each site
$ sudo gedit /etc/apache2/sites-available/foo1.com


$ sudo gedit /etc/apache2/sites-available/foo2.com


$ cd /etc/apache2/sites-enabled/
$ sudo ln -s ../sites-available/foo1.com
$ sudo ln -s ../sites-available/foo2.com

* Add AJP mods to Apache
$ cd /etc/apache2/mods-enabled/
$ sudo ln -s ../mods-available/proxy_ajp.load
$ sudo ln -s ../mods-available/proxy.conf
$ sudo ln -s ../mods-available/proxy.load

* Files in /etc/apache2/mods-availible


* Restart
$ sudo service tomcat6 restart
$ sudo service apache2 restart


/var/log/apache2/httpd-foo1-error.log

[Mon Jun 11 17:16:15 2012] [debug] mod_proxy_ajp.c(45): proxy: AJP: canonicalising URL //127.0.0.1:8009/
[Mon Jun 11 17:16:15 2012] [debug] proxy_util.c(1506): [client 192.168.1.3] proxy: ajp: found worker ajp://127.0.0.1:8009/ for ajp://127.0.0.1:8009/
[Mon Jun 11 17:16:15 2012] [debug] mod_proxy.c(1020): Running scheme ajp handler (attempt 0)
[Mon Jun 11 17:16:15 2012] [debug] mod_proxy_ajp.c(681): proxy: AJP: serving URL ajp://127.0.0.1:8009/
[Mon Jun 11 17:16:15 2012] [debug] proxy_util.c(2011): proxy: AJP: has acquired connection for (127.0.0.1)
[Mon Jun 11 17:16:15 2012] [debug] proxy_util.c(2067): proxy: connecting ajp://127.0.0.1:8009/ to 127.0.0.1:8009
[Mon Jun 11 17:16:15 2012] [debug] proxy_util.c(2193): proxy: connected / to 127.0.0.1:8009
[Mon Jun 11 17:16:15 2012] [debug] proxy_util.c(2444): proxy: AJP: fam 2 socket created to connect to 127.0.0.1
[Mon Jun 11 17:16:15 2012] [debug] ajp_header.c(224): Into ajp_marshal_into_msgb
[Mon Jun 11 17:16:15 2012] [debug] ajp_header.c(290): ajp_marshal_into_msgb: Header[0] [Host] = [www.foo1.com]
[Mon Jun 11 17:16:15 2012] [debug] ajp_header.c(290): ajp_marshal_into_msgb: Header[1] [User-Agent] = [Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:11.0) Gecko/20100101 Firefox/11.0]
[Mon Jun 11 17:16:15 2012] [debug] ajp_header.c(290): ajp_marshal_into_msgb: Header[2] [Accept] = [text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8]
[Mon Jun 11 17:16:15 2012] [debug] ajp_header.c(290): ajp_marshal_into_msgb: Header[3] [Accept-Language] = [en-us,en;q=0.5]
[Mon Jun 11 17:16:15 2012] [debug] ajp_header.c(290): ajp_marshal_into_msgb: Header[4] [Accept-Encoding] = [gzip, deflate]
[Mon Jun 11 17:16:15 2012] [debug] ajp_header.c(290): ajp_marshal_into_msgb: Header[5] [Connection] = [keep-alive]
[Mon Jun 11 17:16:15 2012] [debug] ajp_header.c(290): ajp_marshal_into_msgb: Header[6] [If-Modified-Since] = [Thu, 07 Jun 2012 12:11:41 GMT]
[Mon Jun 11 17:16:15 2012] [debug] ajp_header.c(290): ajp_marshal_into_msgb: Header[7] [If-None-Match] = [W/"1887-1339071101000"]
[Mon Jun 11 17:16:15 2012] [debug] ajp_header.c(290): ajp_marshal_into_msgb: Header[8] [Cache-Control] = [max-age=0]
[Mon Jun 11 17:16:15 2012] [debug] ajp_header.c(450): ajp_marshal_into_msgb: Done
[Mon Jun 11 17:16:15 2012] [debug] mod_proxy_ajp.c(268): proxy: APR_BUCKET_IS_EOS
[Mon Jun 11 17:16:15 2012] [debug] mod_proxy_ajp.c(273): proxy: data to read (max 8186 at 4)
[Mon Jun 11 17:16:15 2012] [debug] mod_proxy_ajp.c(288): proxy: got 0 bytes of data
[Mon Jun 11 17:16:15 2012] [debug] ajp_header.c(687): ajp_read_header: ajp_ilink_received 04
[Mon Jun 11 17:16:15 2012] [debug] ajp_header.c(697): ajp_parse_type: got 04
[Mon Jun 11 17:16:15 2012] [debug] ajp_header.c(516): ajp_unmarshal_response: status = 304
[Mon Jun 11 17:16:15 2012] [debug] ajp_header.c(537): ajp_unmarshal_response: Number of headers is = 2
[Mon Jun 11 17:16:15 2012] [debug] ajp_header.c(599): ajp_unmarshal_response: Header[0] [ETag] = [W/"1887-1339071101000"]
[Mon Jun 11 17:16:15 2012] [debug] ajp_header.c(599): ajp_unmarshal_response: Header[1] [Content-Length] = [0]
[Mon Jun 11 17:16:15 2012] [debug] ajp_header.c(687): ajp_read_header: ajp_ilink_received 05
[Mon Jun 11 17:16:15 2012] [debug] ajp_header.c(697): ajp_parse_type: got 05
[Mon Jun 11 17:16:15 2012] [debug] mod_proxy_ajp.c(590): proxy: got response from (null) (127.0.0.1)
[Mon Jun 11 17:16:15 2012] [debug] proxy_util.c(2029): proxy: AJP: has released connection for (127.0.0.1)


/var/log/apache2/httpd-foo1-access.log

192.168.1.3 - - [11/Jun/2012:17:16:15 +0200] "GET / HTTP/1.1" 304 152 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:11.0) Gecko/20100101 Firefox/11.0"



/var/log/tomcat6/catalina.out

Jun 11, 2012 3:01:39 PM org.apache.coyote.http11.Http11Protocol pause
INFO: Pausing Coyote HTTP/1.1 on http-8080
Jun 11, 2012 3:01:40 PM org.apache.catalina.core.StandardService stop
INFO: Stopping service Catalina
Jun 11, 2012 3:01:40 PM org.apache.coyote.http11.Http11Protocol destroy
INFO: Stopping Coyote HTTP/1.1 on http-8080
Jun 11, 2012 3:24:11 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat6/server/classes], exists: [false], isDirectory: [false], canRead: [false]
Jun 11, 2012 3:24:11 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat6/server], exists: [false], isDirectory: [false], canRead: [false]
Jun 11, 2012 3:24:11 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat6/shared/classes], exists: [false], isDirectory: [false], canRead: [false]
Jun 11, 2012 3:24:11 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat6/shared], exists: [false], isDirectory: [false], canRead: [false]
Jun 11, 2012 3:24:12 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Jun 11, 2012 3:24:12 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 804 ms
Jun 11, 2012 3:24:12 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Jun 11, 2012 3:24:12 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.35
Jun 11, 2012 3:24:12 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor ROOT.xml
Jun 11, 2012 3:24:12 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor ROOT.xml
Jun 11, 2012 3:24:12 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor ROOT.xml
Jun 11, 2012 3:24:13 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Jun 11, 2012 3:24:13 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Jun 11, 2012 3:24:13 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/51 config=null
Jun 11, 2012 3:24:13 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 649 ms
Karl Larsson
Greenhorn

Joined: Apr 12, 2012
Posts: 3
Found the error myself. A short time after I wrote my question. I have fought with this problem for days. :-)

Change the path from:
/etc/tomcat6/Catalina/foo2.com/ROOT.xml

to:
/etc/tomcat6/Catalina/www.foo2.com/ROOT.xml

The same for foo1...
 
jQuery in Action, 2nd edition
 
subject: Two sites with Tomcat 6 and Apache 2.2 (Problem)