February 2015

Gavin Pickin

Adding Lucee Connection Configuration so Apache can Serve Lucee Sites

Apache, CFML Server, Lucee, Server Admin

Working with Apache can be daunting for some, simple for others, we all have our ways to handle it. I really like having individual conf files for each site, to make it easy to update one VirtualHost at a time, and if I want to zap a site, or duplicate it, or automate it, its just simple file changes, I don’t need to parse a whole file.

I manage connections in a similar way, each connection type, CF9, CF10, CF11, Railo, Lucee, would all have its own connection file, that I can include in each of the Virtual Hosts. Easy to manage, update in one file, it extends to all hosts using that include, and of course, keeping it out of your main httpd.conf or the main folder structure helps for ease of update, and gives you automation options etc too. So lets look at how I do it.

I usually setup a folder for all my included conf files, for ColdFusion, Railo, and now Lucee, and inside of that same folder, I’ll make one for {{ServerConf}}/apache. Inside of that folder is each Sites own conf file, named In my main include folder {{ServerConf}} I will have files for each connector, and etc. I am assuming you have your other engines under control, I am going to focus on Lucee today. If you need help with the other engines, look at my presentation on multi engine environments, or look through some of my other blog posts.

What do we put in the file?

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

If you have a different AJP port… well, then you can update the port from 8024 to something else. Pretty straight forward, nothing special here, using a standard AJP port, matching an expression, and now, if we put this in any Virtual Host in apache, any .cfm / .cfc will route the request to Lucee. If you have your server.xml setup with a host pointed at the right location, your site will be served. Before we can do that, lets work on the other inc files, and how we get the includes into the httpd.conf file.

For simplicity sake, I always put my includes at the bottom of these conf files… they can get very long, so usually, thats the easiest place to put them. To include our Apache Virtual Hosts, we can just tell Apache to include all out *.conf files in the {{ServerConf/apache/ folder by adding this to the bottom of our httpd.conf file. Unlike xml, the conf files just end, so you can put this at the VERY BOTTOM without any issues.

#Load Virtual Hosts {{ServerConf}}/apache/*.conf
Include /www/_servers/conf/apache/*.conf

Now we have our virtual hosts being loaded, lets make one for our next Lucee site, and get it hooked up.
In the last post, I showed you how to setup an xml include for lucee hosts, so we’ll set one up for that. The xml gives us the details we need for apache too.

<Host name="" appBase="webapps">
     <Context path="" docBase="/www/JustMockIt"></Context>

So the equivalent apache Virtual Host will be as follows

<VirtualHost *:80>
          DocumentRoot      "/www/JustMockIt/"
          Include                     /www/_servers/conf/

ServerAdmin email is your email
DocumentRoot is the website root, accessible by apache
ServerName      Accessible URL
ServerAlias        If you would like to use more than just the ServerName as the only url, you can add multiple ServerAlias
Include               We’re going to point to our file.

Restart Apache, and ta-daa, its working.


by James
02/05/2015 07:11:41 AM

Hi Gavin,

Enjoying your posts the last couple days. What I'm still not grasping is why not just use mod_cfml? That it's sole purpose so you don't need to restart Tomcat. Just add your site to apache and done. What am I missing? It already comes configured with the Railo/Lucee installer and if you want to do it manually you can just download it from their site.

by Gavin
02/05/2015 08:31:48 AM

Glad you're liking the posts James. I'll have to look into the mod_cfml a little more. I think initially I used it, but I wanted more control with the ajp.

With ajp, I can select which instance of Railo / Lucee I want to run, I could easily flick between CF10 or CF11 which run on Tomcat and ajp as well, and of course, Apache has load balancer configuration which is based on ajp as well, so I guess use what suits you.

Last time I used the mod_cfml it generated this

PerlRequire /opt/railoa/tomcat_connectors/mod_cfml/
PerlHeaderParserHandler mod_cfml
PerlSetVar LogHeaders false
PerlSetVar LogHandlers false
PerlSetVar CFMLHandlers ".cfm .cfc .cfml"

If I wanted to change ports etc, doesn't seem as open to me, but why use an external perl module, and ajp is built in?

I think I got the ajp stuff out of some Railo presentations, and probably thought if they recommend it, its good enough for me.

That's me... but whatever works.

Thanks for the feedback. If anyone else knows why mod_cfml is better, please let me know. I am only as good as my experience, I am open to suggestion.

by James
02/08/2015 01:37:27 PM


Sorry I took a couple days to get back:) When I re-read your article I realized that mod_cfml wouldn't fit the needs of what you are trying to do with your overall setup.

You are dealing with ACF as well so your setup definitely gives you more control for what you are trying to accomplish.

Originally all I was trying to say is that your basic railo installer setup is not a hassle because it already installs mod_cfml and all you have to do is add site to apache and done. It takes care of tomcat for you. My feeling was it doesn't get much simpler that.

by Gavin
02/08/2015 10:09:45 PM

Thanks for the feedback. We're all learning, its why I share, so I can learn, and have something to refer to later, and a lot of the time, someone else will see something, and say, ACTUALLY, then we both learn and grow.

I think I did use mod_cfml some, but once I started hacking, it got messy, pretty quick.

I think you'll like my next post, its how to run Apache with a single instance of Tomcat, I think its similar to how the mod_cfml handles it. The big plus, it still works with ajp or http and you can still cluster.

I'm going to try and write that one up now.

Blog Search