Apache on CentOS

Install mod_cfml to Apache on 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, 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_cfml

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

wget -O mod_cfml-master.zip https://github.com/utdream/mod_cfml/archive/master.zip

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

yum -y install unzip
unzip mod_cfml-master.zip

Now, go into the unzipped directory "mod_cfml-master/C/", and use the Make program to compile mod_cfml.so, and add it into Apache's modules directory:

cd ./mod_cfml-master/C
yum -y install httpd-devel gcc
sudo make
sudo make install

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

/etc/httpd/conf/httpd.conf

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

LoadModule modcfml_module modules/mod_cfml.so
CFMLHandlers ".cfm .cfc .cfml"
ModCFML_SharedKey "secret key also set in the Tomcat valve config"
# Optional, all for logging and debugging:
# LogHeaders true
# LogHandlers true
# LogAliases true
# VDirHeader false

Again, note that this is configured for CFML requests. You can edit the "CFMLHandlers" 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.