Installing coldfusion with Apache

Published by

Posted on December 05, 2007

Compiling and Installing the Apache module for CFMX from source code
This example was tested on a server running Redhat Linux 8 and Apache 2.0.46 built from source. Click on the link for instructions on installing from source.

Install updater 3 or greater
The source code for the ColdFusion Apache module was included in CFMX updater 3, so step one is to install Updater 3 or higher from Macromedia. In this particular case CFMX was already installed using the standalone server, so if your are installing from scratch choose that option.

Extract the module source code
The source is located in the coldfusionmx/runtime/lib/ directory inside the wsconfig.jar file. Jar files are Java Archive files, and they use the same compression as zip files, so you can treat them like zip files.

cp /opt/coldfusionmx/runtime/lib/wsconfig.jar .
unzip wsconfig.jar

This creates several directories but in connectors/src/ the source for the Apache module resides. Unzip the file ApacheModule.zip
cd connectors/src
unzip ApacheModule.zip

Compile the Apache Module
In the src directory is a file called ApacheBuildInstructions.txt, read this file. This file is the basis of our instructions for this step.

cat ApacheBuildInstructions.txt

We have crafted a build script that does most of the work for you, you just need to make sure the the paths are correct in the build script:
#!/bin/bash
#CFMX path eg: /opt/coldfusionmx
export CFMX=/opt/coldfusionmx

#apache path eg: /usr/local/apache2
export APACHE_PATH=/usr/local/apache2

#apache bin path eg: $APACHE_PATH/bin
export APACHE_BIN=$APACHE_PATH/bin

#CFMX connector path eg $CFMX/runtime/lib/wsconfig/1
export CFMX_CONNECTOR=$CFMX/runtime/lib/wsconfig/1

#stop apache
$APACHE_BIN/apachectl stop

${APACHE_BIN}/apxs -c -Wc,-w -n jrun20 -S LIBEXECDIR=${CFMX_CONNECTOR} mod_jrun20.c \
jrun_maptable_impl.c jrun_property.c jrun_session.c platform.c \
jrun_mutex.c jrun_proxy.c jrun_ssl.c

${APACHE_BIN}/apxs -i -n jrun20 -S LIBEXECDIR=${CFMX_CONNECTOR} mod_jrun20.la

strip $CFMX_CONNECTOR/mod_jrun20.so

Before you run this script (note: you can also just type it in by hand) make sure that the directory for the CFMX_CONNECTOR exists (runtime/lib/wsconfig/1). You will probably need to make this directory:
mkdir /opt/coldfusionmx/runtime/lib/wsconfig/1

If the directory already exists create a directory called 2 instead of 1, and update the CFMX_CONNECTOR variable in the script. Now save the script above in a file, we assume you called it build.sh. You need to mark it as executable with chmod, and then run it.
chmod u+x build.sh
./build.sh

Now you have built the mod_jrun20.so file, and it resides in your CFMX_CONNECTOR directory.

Configure ColdFusion MX to work with Apache First stop ColdFusion MX:

service coldfusionmx stop

Now edit the file /opt/coldfusionmx/runtime/servers/default/SERVER-INF/jrun.xml it may be a good idea to keep a backup of this file before you edit it. Below is the settings you will want to change, with changes in Bold (approx line 350):
8500
*
true
10
10
300
1000

51010
false
10
10
300

false
500
0

The cacheRealPath attribute may be left to true if your only running one web site on the apache server, but if you are running multiple sites you will want to set it to false.

Configure apache for ColdFusion
The Apache httpd.conf file needs to be told to load the module, and also told that index.cfm should be used as a directory index. To accomplish this, I like to create a directory called conf.d in my apache directory /usr/local/apache2/conf.d/ and then create a file called coldfusion.conf. If I have other modules such as php, I create a php.conf file. This allows you to easily edit module specific settings. So to do this I need to tell httpd.conf about my conf.d directory, I do this by adding the following line to the httpd.conf file:

Include conf.d/*.conf

you will want to make sure that your httpd.conf file does not already have this line in it, to search your file run:
grep conf.d httpd.conf

It will not output anything if it does not find the string conf.d in httpd.conf

Now lets create conf.d/coldfusion.conf with the following contents:

LoadModule jrun_module “/opt/coldfusionmx/runtime/lib/wsconfig/1/mod_jrun20.so”

JRunConfig Verbose false
JRunConfig Apialloc false
JRunConfig Ssl false
JRunConfig Ignoresuffixmap false
JRunConfig Serverstore “/opt/coldfusionmx/runtime/lib/wsconfig/1/jrunserver.store”
JRunConfig Bootstrap 127.0.0.1:51010
#JRunConfig Errorurl optionally redirect to this URL on errors
AddHandler jrun-handler .cfm .cfc .cfml .jsp .jws

DirectoryIndex index.cfm

Start ColdFusion and Apache

service coldfusionmx start

service apache start