LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   virtual hosts with apache and tomcat (http://www.linuxquestions.org/questions/linux-server-73/virtual-hosts-with-apache-and-tomcat-716481/)

mfoley 04-02-2009 10:20 PM

virtual hosts with apache and tomcat
 
have been using apache and tomcat on linux for a while now, but only configured as a single domain. Now I want to use multiple virtual hosts. My configuration is not working. It loads the page, but doesn't execute the jsp code which tells me the system is paying attention to the virtual host path, but not the JKmount info. Here's what I have so far:

Linux kernel 2.6.27, slackware
apache 2.2.11
tomcat 6.0.18

httpd.conf
-------------
LoadModule jk_module lib/mod_jk.so
JkWorkersFile conf/workers.properties
JkShmFile /var/log/httpd/mod_jk.shm
JkLogFile logs/mod_jk.log
JkLogLevel info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JkMount /examples/* worker1
JkMount /examples worker1
:
<VirtualHost *>
ServerName www.fluxrunner.com
DocumentRoot /usr/local/apache/htdocs
</VirtualHost>

<VirtualHost *>
ServerName www.courtscan.com
DocumentRoot /www/courtscan
<directory /www/courtscan>
allow from all
</directory>
CustomLog /www/courtscan/logs/access_log combined
ErrorLog /www/courtscan/logs/error_log
</VirtualHost>

workers.properties
----------------------
worker.list=worker1,courtscan
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009

worker.courtscan.type=ajp13
worker.courtscan.host=localhost
worker.courtscan.domain=courtscan.com
worker.courtscan.port=8009
worker.courtscan.mount=/www/courtscan /www/courtscan/*

server.xml
-------------
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
</Host>

<Host name="courtscan.com" appBase="/www/courtscan" >
<Logger className="org.apache.catalina.logger.FileLogger" directory="logs/" prefix="courtscan_access_log" suffix=".log" timestamp="true"/>

<Context path="/" docBase="/www/courtscan" reloadable="false">
<WatchedResource>/WEB-INF/web.xml</WatchedResource>
</Context>
</Host>

I think I'm close ...

tizzef 04-06-2009 05:06 AM

Hi,

You should probably use some triks like this :

virtual1.conf :

<VirtualHost 192.168.0.100:80>
DocumentRoot /var/www/virtual1.com
ServerName virtual1.com
</VirtualHost>

virtual2.conf :

<VirtualHost 192.168.0.100:80>
DocumentRoot /var/www/virtual2.com
ServerName virtual2.com
</VirtualHost>


If you have multiple domain name for one @IP.

Have a look here : http://httpd.apache.org/docs/2.0/vhosts/

Cheers

mfoley 04-23-2009 12:00 PM

I've returned to this thread because I've run into more problems. My configuration is such that ALL web requests are being routed to tomcat. For example, http://www.courtscan.com is supposed to get jsp docs from /www/tomcat/webapps/courtscan ... which it does. However, http://www.buffalotouch.com is supposed to get html docs from /www/buffalotouch, which it does not. Instead, I get a the default tomcat local home page. I'm sure I have to change something with the server.xml context/document/appBase paths, or perhaps the mount directive in workers.properties, but I'm clueless as to where to start.

Bbelow are the relevant sections of my current httpd.conf, workers.properties and server.xml files:

##### httpd.conf
LoadModule jk_module lib/mod_jk.so
JkWorkersFile conf/workers.properties
JkShmFile /var/log/httpd/mod_jk.shm
JkLogFile logs/mod_jk.log
JkLogLevel info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
##########Virtual hosts section of httpd.conf############
<VirtualHost *>
ServerName www.fluxrunner.com
DocumentRoot /usr/local/apache/htdocs
</VirtualHost>

<VirtualHost *>
ServerName www.courtscan.com
DocumentRoot /www/courtscan
<directory /www/courtscan>
allow from all
</directory>
CustomLog /www/courtscan/logs/access_log combined
ErrorLog /www/courtscan/logs/error_log
</VirtualHost>

<VirtualHost *>
ServerName www.buffalotouch.com
DocumentRoot /www/buffaloTouch
<directory /www/buffaloTouch>
allow from all
</directory>
CustomLog /www/buffaloTouch/logs/access_log combined
ErrorLog /www/buffaloTouch/logs/error_log
</VirtualHost>

#######workers.properties file################
worker.list=courtscan
worker.courtscan.type=ajp13
worker.courtscan.host=localhost
worker.courtscan.port=8009
worker.courtscan.mount=/ /*

####Host tags in server.xml file##########
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
</Host>

<Host name="www.courtscan.com" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Alias>courtscan.com</Alias>
<Logger className="org.apache.catalina.logger.FileLogger" directory="logs/" prefix="courtscan_access_log" suffix=".log" timestamp="true"/>

<Context path="" docBase="courtscan" reloadable="false">
<WatchedResource>/WEB-INF/web.xml</WatchedResource>
</Context>
</Host>


All times are GMT -5. The time now is 09:25 AM.