I recently built out a simple single task application for a call center and decided it would be a great use case to install Lucee as the ColdFusion engine. The Lucee windows installer comes bundled with an IIS connection script, but no option to connect Apache. Here is what is needed to get it running.
After a bit of Googling, I decided the best approach would be to leverage the mod_cfml module for the task.
From the mod_cfml website:
Mod_cfml is a community-driven suite of programs that automatically configures Tomcat hosts to match hosts created in Apache or IIS. Mod_cfml removes the need to configure web sites twice - once in your web server and again in Tomcat - and performs this task automatically for you.
The flowchart does a nice job of laying out how all of the pieces work together. The good news is that the Lucee installer comes bundled with the mod_cfm-valve.jar already installed and configured in the Tomcat server.xml configuration file. So in order to get things working you just need to focus on configuring Apache.
The mod_cfml website has some good documentation on configuring Apache which I used in this write up. That said, I followed the directions to the letter but still ran into a bit of snag which I will point out below.
Prerequisites & Assumptions:
- Configuring Lucee 5.1 for use with Apache 2.4 on Windows.
- Lucee 5.1 was installed using the windows installer.
- Apache 2.4 binary was installed from ApacheHaus or Apache Lounge.
- mod_cfml.so requires Visual C++ 2010 SP1 Redistributable Package: Win64 vcredist_x64.exe, Win32 vcredist_x86.exe
Step1. Configure mod_proxy
Both the ApacheHaus and Apache Lounge binaries include the needed mod_proxy modules but they are disabled by default. To enable them, the following lines must be uncommented in the Apache configuration file. C:/Apache24/conf/httpd.conf
First search for these two lines:
#LoadModule proxy_module modules/mod_proxy.so
#LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
Next uncomment the lines by removing the "#"
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
Now that the mod_proxy modules are enabled place the following code at the bottom of your httpd.conf file to tell Apache to route .cfm files to Tomcat for processing.
** Here is where I ran into a snag... **
In the code snippit above it states the following on lines 4 and 5:
# When using Apache 2.4, use this line (without the "# ")
# Require ip 127.0.0.1
So I uncommented line 5 "Require ip 127.0.0.1".
It took me some time to figure it out, but this line was causing a "Forbidden You don't have permission to access /index.cfm on this server." error in the browser.
In the Apache error log the error looked like this:
"AH01630: client denied by server configuration: proxy:ajp://localhost:8009/index.cfm"
To resolve this error I updated the code above to this:
Step2. Installing mod_cfml.so
Download the proper mod_cfml module to match your Apache 2.4 install type (64bit or 32 bit).
Once downloaded, move the mod_cfml.so file to your Apache modules directory
Next Copy and paste the code below into the bottom of your Apache C:/Apache24/conf/httpd.conf file to load the mod_cfml module.
On Line 3 of the snippet you will need to update the "ModCFML_SharedKey" value with the value already configured in your Lucee "server.xml" configuration file located in the C:/lucee/tomcat/conf/ directory.
Finally restart Apache in the Windows services panel or by using ApacheMonitor.exe located in the C:/Apache24/bin/ directory.
To test the setup I created a simple index.cfm flie and saved it to the Apache root directory C:/Apache24/htdocs/index.cfm.