ModCFML

Apache on RedHat/CentOS

The following steps cover all the steps necessary for install the mod_cfml.pm module into Apache on a RedHat-based system (like CentOS). The steps are intended to be thorough, so you may not need to take each step on your own system. For example, you may already have Apache and some of the required modules installed on your system.

All steps provided are done from the command-line for uniformity. If you have a graphic desktop, you can perform these steps by opening a terminal window and running these commands.

Installing Apache

installing Apache on a CentOS system can be accomplished with the following commands:

yum -y install httpd

Once Apache is installed, you can start Apache with the following:

service httpd start

You can configure your Apache install to start on when your system boots up with the following command:

chkconfig httpd on

Configuring mod_proxy

Mod_proxy is a connector, that is, it passes requests off to Tomcat for processing, thus "connecting" Apache to Tomcat. Both mod_proxy and mod_jk have been tested with mod_cfml and both work great. If you already have mod_proxy or mod_jk installed, then you may skip this step. However, since you do need one or the other installed, we will cover installing mod_proxy quickly here. This is not intended to be documentation on mod_proxy, but enough to get you up and running. Full mod_proxy documentation is avaialble on the Apache Web Site.

mod_proxy and mod_proxy are part of the default installations on CentOS4 and CentOS5, but just to be safe, you can check to make sure they're present in your Apache config by running the following command:

httpd -M 2>&1 | grep proxy

You should see something similar to the following:

proxy_module (shared)
proxy_balancer_module (shared)
proxy_ftp_module (shared)
proxy_http_module (shared)
proxy_connect_module (shared)
proxy_ajp_module (shared)

In the above list, the proxy modules you'll be REQUIRED to have are proxy_module, proxy_http_module, and proxy_ajp_module. However, most default Apache installs will have output like the above. If you do to, then you're good to go.

Next we need to configure the proxy to send the kind of requests we want off to Tomcat. You do that by editing this file:

/etc/httpd/conf/httpd.conf


and add the following to the very bottom of the file:

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


The config above is designed to send any request that Apache gets that has a ".cfm" or ".cfc" in it to be passed off to Tomcat. This configuration is obviously intended for CFML processing engines like Railo or OpenBD, but you can also use a statement similar to the above to pass ".jsp" files off to Tomcat, and mod_cfml will create contexts for those sites as well. Feel free to experiment here however you need to.

Now restart Apache so your changes take effect:

service httpd restart

Once that's done, requests to something like http://[server-ip]/index.cfm should be working for you.

Installing mod_perl

The mod_cfml.pm module requires mod_perl, so we need to install and enable that module in addition to whatever connector module we're using. To install mod_perl in Ubuntu, run the following command:

yum -y install mod_perl

For the record, your mod_perl config should now be located in this file:

/etc/httpd/conf.d/perl.conf


This file should be loaded by default, but just in case it's not, you need to have a line like this in your main Apache config file (/etc/httpd/conf/httpd.conf):

Include conf.d/*.conf


If the above line is NOT present in your main Apache config file, mod_perl will not be loaded and you'll get errors when you attempt to move further in these instructions. You can test is mod_perl is being loaded with the following command:
 

httpd -M 2>&1 | grep perl

you should get the following response:

 perl_module (shared)

If you do NOT get the "perl_module" response, check check to make sure the config is loading, like mentioned above. If you do get the same response as above, then you should be good to proceed.

Installing mod_cfml

Now, after all the preperation, we can finally install our mod_cfml module. If you haven't already, go download the mod_cfml.pm.zip file. You can download the mod_cfml.pm.zip file directly to the server you're installing it on using the "wget" command:

wget http://download.modcfml.org/downloader.cfm/id/3/file/mod_cfml.pm.zip

IMPORTANT! The link above points to version 1.0.0 of mod_cfml. Mod_cfml may have been upgraded since this documentation was written, so you may need to use an updated URL.

Next we need to unzip the file. You can do that using the "unzip" command:

unzip mod_cfml.pm.zip

and move it to it's permanant home... this can be wherever you want. The following is just an example. I'm going to imagine that I already have a Railo install that I'm now installing mod_cfml into.

mkdir -p /opt/railo/connector/
mv mod_cfml.pm /opt/railo/connector/

Now we add our mod_cfml configs to Apache. Open this file:

/etc/httpd/conf/httpd.conf


... and add the following config to the very bottom of the file:

PerlRequire "/path/to/mod_cfml.pm"
PerlHeaderParserHandler mod_cfml
PerlSetVar LogHeaders false
PerlSetVar LogHandlers false
PerlSetVar CFMLHandlers ".cfm .cfc .cfml"


Again, note that this is configured for CFML requests. You can edit the "Handlers" value for the kinds of files that you're sending to Tomcat. (JSP or whatever). By default, mod_cfml will also update the headers on requests for default documents (any request ending in a slash: "/" ), so you don't need to worry about adding that as a handler.

What's Next?

Now that you have the mod_cfml.pm installed, you'll need to install the Tomcat Valve. The Tomcat Valve will take the information that the mod_cfml.pm file is sending it, and create the hosts automatically using that data.