0

I need to run ColdFusion apps on my existing PHP server (Linux). I installed railo with tomcat on the server, but Railo is hogging all the traffic. I want it installed such that only requests to files within /webapps/ROOT/ go through the Railo server, and all others through the existing php server. The server is not my own, and my installation of Railo is breaking other users' sites.

Is there any way I can do this?

P.S.: I am not very proficient with Linux and the company that owns it has totally crap support, so talking to them is taking one step forward and two steps back.

Pranav Hosangadi
  • 103
  • 1
  • 1
  • 5

2 Answers2

4

You need to install mod_jk or mod_proxy to forward requests from the Apache to Tomcat.

Here's an example with mod_jk.

  1. Install Tomcat
  2. Download the *.war file into webapps folder and rename to railo.war.
  3. Install mod_jk
  4. Create/edit the workers.properties file as belows:

    worker.list=worker1
    
    worker.worker1.type=ajp13
    worker.worker1.host=127.0.0.1
    worker.worker1.port=8009
    
  5. Create a mod_jk.conf file:

    LoadModule          jk_module modules/mod_jk.so
    
    JkWorkersFile       /etc/httpd/conf/workers.properties
    JkShmFile           /var/log/httpd/jk.shm
    
    JkLogFile           /var/log/httpd/mod_jk.log
    JkLogLevel          info
    JkLogStampFormat    "[%a %b %d %H:%M:%S %Y] "
    
    <VirtualHost *:80>
        ServerName      your.domain.com
        JkMount         /railo/* worker1
    </VirtualHost>
    
  6. Add a virtual host for Tomcat:

      <Host name="your.domain.com"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">
        <Context path="/railo" docBase="railo"/>
      </Host>
    

It means that the request to http://your.domain.com/railo will be forward to Tomcat, at railo context and other requests are still served by Apache.

quanta
  • 50,327
  • 19
  • 152
  • 213
2

Mod Proxy example (credit Jamie Krug for simplifying this):

httpd.conf

<Proxy *>
Allow from 127.0.0.1
</Proxy>
ProxyPreserveHost On
ProxyPassMatch ^/(.+\.cf[cm])(/.*)?$ ajp://localhost:8009/$1$2

<VirtualHost *:80>
    ServerName testhost1
    DocumentRoot "/path/to/testhost1"
    DirectoryIndex index.html index.cfm
    ErrorLog "logs/testhost1-error.log"
    CustomLog "logs/testhost1-access.log" common
</VirtualHost>
<VirtualHost *:80>
    ServerName testhost2
    DocumentRoot "/path/to/testhost2"
    DirectoryIndex index.html index.cfm
    ErrorLog "logs/testhost2-error.log"
    CustomLog "logs/testhost2-access.log" common
</VirtualHost>

server.xml (Tomcat)

Make sure that these are defined above the definition of LOCALHOST

<Host name="testhost1" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
    <Context path="" docBase="/path/to/testhost1" />
</Host>
<Host name="testhost2" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
    <Context path="" docBase="/path/to/testhost2" />
</Host>
webRat
  • 41
  • 2