Blog

15
May 2014

Gavin Pickin

Multi CFML Engine Install - Extracting the ColdFusion 9 Connector for Apache

CFML Server, Server Admin

We are going to setup apache with virtual hosts to deliver multiple CFML engines.
To do so, we need to setup the cfml engine adapters / connectors, 1 by 1, and remove their connector code from the main httpd.conf and then include that connector string in the Vhosts themselves, while leaving any LOAD MODULE code in the main httpd.conf, because we only want to load the module once, and because you cannot load modules in a Virtual Host. This way, we can designate which sites use what connector. Lets do ColdFusion 9.

Apache Test File

To test we're going to use a page called index2.cfm
Go to our apache root, /home/www/default (in our case)
nano index2.cfm

<h1>Apache Root</h1>
<cfdump var="#server#">

CTRL X
Y
[ Enter ]

No, lets try the page

http://[machinename]/index2.cfm
Apache displayed the source of the page, because its not prepared to server the CFML in it, it just shows it.

Ok, so now, we're going to setup one of our CFML Engines.

Pre Connector for ColdFusion

First we have to make sure we have https-devel installs
yum install httpd-devel

Fixing the Adobe Connection Shell

On centos you need to edit the coldfusion9/bin/connectors/apache_connectors.sh

Originally is….
../../runtime/bin/wsconfig \
        -server coldfusion \
    -ws apache \
        -dir /usr/local/apache2/conf \
        -bin /usr/local/apache2/bin/httpd \
        -script /usr/local/apache2/bin/apachectl \
        -coldfusion

exit $#

This refers to /usr/local/apache2 as the location of apache.
Update it to /etc/httpd instead for the -dir line,
 -bin line should be /usr/sbin/httpd
The -script line needs to point to the bin, so update it to /etc/rc.d/init.d/httpd

../../runtime/bin/wsconfig \
        -server coldfusion \
    -ws apache \
           -dir /etc/httpd/conf \
    -bin /usr/sbin/httpd \
    -script /etc/rc.d/init.d/httpd \
        -coldfusion
    -w64
    -v

exit $#

Compiling the Connector

Run it by ./apache_connectors.sh
If you get a GCC not found error, you might have to install some development tools,  to allow you to build the connector.
yum groupinstall 'Development Tools'

Run it again, and it will compile.
If you care what it MIGHT say, this is what it told me :)


CentOS release 6.4 (Final)
Server's Module Magic Number: 20051115:25.  Supported major magic numbers on this platform are 20020628 and 20020903.
Attempting to build connector from sources
Server version: Apache/2.2.15 (Unix)
/usr/lib64/apr-1/build/libtool --silent --mode=compile gcc -prefer-pic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -Wformat-security -fno-strict-aliasing  -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -pthread -I/usr/include/httpd  -I/usr/include/apr-1   -I/usr/include/apr-1  -w  -c -o /opt/coldfusion9/runtime/lib/wsconfig/1/mod_jrun22.lo /opt/coldfusion9/runtime/lib/wsconfig/1/mod_jrun22.c && touch /opt/coldfusion9/runtime/lib/wsconfig/1/mod_jrun22.slo
/usr/lib64/apr-1/build/libtool --silent --mode=compile gcc -prefer-pic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -Wformat-security -fno-strict-aliasing  -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -pthread -I/usr/include/httpd  -I/usr/include/apr-1   -I/usr/include/apr-1  -w  -c -o /opt/coldfusion9/runtime/lib/wsconfig/1/jrun_maptable_impl.lo /opt/coldfusion9/runtime/lib/wsconfig/1/jrun_maptable_impl.c && touch /opt/coldfusion9/runtime/lib/wsconfig/1/jrun_maptable_impl.slo
/usr/lib64/apr-1/build/libtool --silent --mode=compile gcc -prefer-pic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -Wformat-security -fno-strict-aliasing  -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -pthread -I/usr/include/httpd  -I/usr/include/apr-1   -I/usr/include/apr-1  -w  -c -o /opt/coldfusion9/runtime/lib/wsconfig/1/jrun_mutex.lo /opt/coldfusion9/runtime/lib/wsconfig/1/jrun_mutex.c && touch /opt/coldfusion9/runtime/lib/wsconfig/1/jrun_mutex.slo
/usr/lib64/apr-1/build/libtool --silent --mode=compile gcc -prefer-pic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -Wformat-security -fno-strict-aliasing  -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -pthread -I/usr/include/httpd  -I/usr/include/apr-1   -I/usr/include/apr-1  -w  -c -o /opt/coldfusion9/runtime/lib/wsconfig/1/jrun_property.lo /opt/coldfusion9/runtime/lib/wsconfig/1/jrun_property.c && touch /opt/coldfusion9/runtime/lib/wsconfig/1/jrun_property.slo
/usr/lib64/apr-1/build/libtool --silent --mode=compile gcc -prefer-pic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -Wformat-security -fno-strict-aliasing  -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -pthread -I/usr/include/httpd  -I/usr/include/apr-1   -I/usr/include/apr-1  -w  -c -o /opt/coldfusion9/runtime/lib/wsconfig/1/jrun_proxy.lo /opt/coldfusion9/runtime/lib/wsconfig/1/jrun_proxy.c && touch /opt/coldfusion9/runtime/lib/wsconfig/1/jrun_proxy.slo
/usr/lib64/apr-1/build/libtool --silent --mode=compile gcc -prefer-pic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -Wformat-security -fno-strict-aliasing  -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -pthread -I/usr/include/httpd  -I/usr/include/apr-1   -I/usr/include/apr-1  -w  -c -o /opt/coldfusion9/runtime/lib/wsconfig/1/jrun_session.lo /opt/coldfusion9/runtime/lib/wsconfig/1/jrun_session.c && touch /opt/coldfusion9/runtime/lib/wsconfig/1/jrun_session.slo
/usr/lib64/apr-1/build/libtool --silent --mode=compile gcc -prefer-pic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -Wformat-security -fno-strict-aliasing  -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -pthread -I/usr/include/httpd  -I/usr/include/apr-1   -I/usr/include/apr-1  -w  -c -o /opt/coldfusion9/runtime/lib/wsconfig/1/jrun_utils.lo /opt/coldfusion9/runtime/lib/wsconfig/1/jrun_utils.c && touch /opt/coldfusion9/runtime/lib/wsconfig/1/jrun_utils.slo
/usr/lib64/apr-1/build/libtool --silent --mode=compile gcc -prefer-pic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -Wformat-security -fno-strict-aliasing  -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -pthread -I/usr/include/httpd  -I/usr/include/apr-1   -I/usr/include/apr-1  -w  -c -o /opt/coldfusion9/runtime/lib/wsconfig/1/platform.lo /opt/coldfusion9/runtime/lib/wsconfig/1/platform.c && touch /opt/coldfusion9/runtime/lib/wsconfig/1/platform.slo
/usr/lib64/apr-1/build/libtool --silent --mode=link gcc -o /opt/coldfusion9/runtime/lib/wsconfig/1/mod_jrun22.la  -rpath /usr/lib64/httpd/modules -module -avoid-version    /opt/coldfusion9/runtime/lib/wsconfig/1/platform.lo /opt/coldfusion9/runtime/lib/wsconfig/1/jrun_utils.lo /opt/coldfusion9/runtime/lib/wsconfig/1/jrun_session.lo /opt/coldfusion9/runtime/lib/wsconfig/1/jrun_proxy.lo /opt/coldfusion9/runtime/lib/wsconfig/1/jrun_property.lo /opt/coldfusion9/runtime/lib/wsconfig/1/jrun_mutex.lo /opt/coldfusion9/runtime/lib/wsconfig/1/jrun_maptable_impl.lo /opt/coldfusion9/runtime/lib/wsconfig/1/mod_jrun22.lo
/usr/lib64/httpd/build/instdso.sh SH_LIBTOOL='/usr/lib64/apr-1/build/libtool' /opt/coldfusion9/runtime/lib/wsconfig/1/mod_jrun22.la /opt/coldfusion9/runtime/lib/wsconfig/1/
/usr/lib64/apr-1/build/libtool --mode=install cp /opt/coldfusion9/runtime/lib/wsconfig/1/mod_jrun22.la /opt/coldfusion9/runtime/lib/wsconfig/1//
libtool: install: cp /opt/coldfusion9/runtime/lib/wsconfig/1/.libs/mod_jrun22.so /opt/coldfusion9/runtime/lib/wsconfig/1//mod_jrun22.so
libtool: install: cp /opt/coldfusion9/runtime/lib/wsconfig/1/.libs/mod_jrun22.lai /opt/coldfusion9/runtime/lib/wsconfig/1//mod_jrun22.la
libtool: install: cp /opt/coldfusion9/runtime/lib/wsconfig/1/.libs/mod_jrun22.a /opt/coldfusion9/runtime/lib/wslibtool: install: warning: remember to run `libtool --finish /usr/lib64/httpd/modules'
config/1//mod_jrun22.a
libtool: install: chmod 644 /opt/coldfusion9/runtime/lib/wsconfig/1//mod_jrun22.a
libtool: install: ranlib /opt/coldfusion9/runtime/lib/wsconfig/1//mod_jrun22.a
chmod 755 /opt/coldfusion9/runtime/lib/wsconfig/1//mod_jrun22.so
Stopping httpd: [  OK  ]
Starting httpd: [  OK  Restarted Apache server
The Apache connector was installed to /etc/httpd/conf
]
./apache_connector.sh: line 17: -w64: command not found
./apache_connector.sh: line 18: -v: command not found

What does it do. Lets have a look at the new https.conf

DirectoryIndex - it adds index.cfm to the end of the line. Re-order this if you want or need to.


It will also add the connector module, which it compiles, and creates on your machine... as you can see by looking closely at the LoadModule line.

# JRun Settings
LoadModule jrun_module /opt/coldfusion9/runtime/lib/wsconfig/1/mod_jrun22.so

<IfModule mod_jrun22.c>
    JRunConfig Verbose false
    JRunConfig Apialloc false
    JRunConfig Ignoresuffixmap false
    JRunConfig Serverstore /opt/coldfusion9/runtime/lib/wsconfig/1/jrunserver.s$
    JRunConfig Bootstrap 127.0.0.1:51011
    #JRunConfig Errorurl url <optionally redirect to this URL on errors>
    #JRunConfig ProxyRetryInterval 600 <number of seconds to wait before trying$
    #JRunConfig ConnectTimeout 15 <number of seconds to wait on a socket connec$
    #JRunConfig RecvTimeout 300 <number of seconds to wait on a socket receive $
    #JRunConfig SendTimeout 15 <number of seconds to wait on a socket send to a$
AddHandler jrun-handler .jsp .jws .cfm .cfml .cfc .cfr .cfswf
</IfModule>

Lets Test the Connector

Test the connector, to make sure it works, for your default website
http://[machinename]/index2.cfm
Apache and server dump shows up… wait, what?

Yes, CF runs the files served from the same vhost as apache.

It we go to http://[machinename]:8500/index2.cfm
We get a cold fusion missing file error… because index2.cfm is not in /opt/coldfusion/wwwroot
If you go to 8500, you're forcing the built in CF Webserver to serve files.

So, Adobe Coldfusion does make setting up hosts easier, once its setup in Apache, and the Adobe Coldfusion connector is attached to the host, it will work.
Railo, you need to setup the host in tomcat as well.
More flexibility, but more complexity, but the AJP is much easier to connect than all the compilation from Source.

But we're done, now we have all of the connectors.

Extract the Connector

So, go and CUT the 2nd part of the code out of the https.conf , and save it for later.

Cut the following into inc_cf9_module.inc
# JRun Settings
LoadModule jrun_module /opt/coldfusion9/runtime/lib/wsconfig/1/mod_jrun22.so

Cut this piece into a separate file called inc_cf9_conn.inc - Remember, your OS and pathing affects this, so you cannot just copy this.

<IfModule mod_jrun22.c>
    JRunConfig Verbose false
    JRunConfig Apialloc false
    JRunConfig Ignoresuffixmap false
    JRunConfig Serverstore /opt/coldfusion9/runtime/lib/wsconfig/1/jrunserver.store
    JRunConfig Bootstrap 127.0.0.1:51011
    #JRunConfig Errorurl url <optionally redirect to this URL on errors>
    #JRunConfig ProxyRetryInterval 600 <number of seconds to wait before trying $
    #JRunConfig ConnectTimeout 15 <number of seconds to wait on a socket connect$
    #JRunConfig RecvTimeout 300 <number of seconds to wait on a socket receive t$
    #JRunConfig SendTimeout 15 <number of seconds to wait on a socket send to a $
    AddHandler jrun-handler .jsp .jws .cfm .cfml .cfc .cfr .cfswf
</IfModule>

Then restart apache
service httpd restart
Then test again, and you should just see the file source code again.

Ok, now we have our CFML Engine Connector Code separated, and tested… we're ready to setup vhosts.. and include the various files depending on the engine of choice... check back for that post soon.

 

 

Blog Search