Sebastian Mogilowskis Blog

Just another blog about administration, linux and other stuff

Install Coldfusion 8 Multiserver on Debian 5.0 Lenny with Apache 2

This article describes, how to install Adobe Coldfusion 8 with Multiserver configuration. You can use this configuration for an ISP like coldfusion setup. Each instance/virtual host will have its own Coldfusion administrator with custom settings.

1. Prerequirements:

* Apache 2 is installed and running correctly.

* libstdc++5 is installed.

aptitude install libstdc++5

* You have a domain for your virtual hosts. (www.testsrv.local)

* You have downloaded the latest linux coldfusion installer from www.adobe.com (coldfusion-801-lin64.bin for example)

2. Install coldfusion:

chmod +x coldfusion-801-lin64.bin
./coldfusion-801-lin64.bin

Note: This is the 64-Bit installer. If you don’t have an 64-bit operating system, you need the 32-bit version (coldfusion-801-lin.bin).

Configuration settings:

CHOOSE LOCALE BY NUMBER: 1
PRESS <ENTER> TO CONTINUE: <ENTER>
PRESS <ENTER> TO CONTINUE: <ENTER>
...
DO YOU ACCEPT THE TERMS OF THIS LICENSE AGREEMENT? (Y/N): Y
Installation Choice: 1 (Install new version of Adobe ColdFusion 8 with a serial number)
Serial Number: XXXX-XXXX-XXXX-XXXX-XXXX-XXXX
Choose one of the following options:: 2 (Multiserver configuration)
Is there already a multiserver configuration of Adobe ColdFusion 8, or Macromedia JRun 4, installed?: 2 (No)
Select an option: 5 (Continue with installation)
Default Install Folder: /opt/jrun4 <ENTER>
PRESS <ENTER> TO CONTINUE: <ENTER>
PRESS <ENTER> TO CONTINUE: <ENTER>
...
DO YOU ACCEPT THE TERMS OF THIS LICENSE AGREEMENT? (Y/N): Y
Serial Number:: <ENTER>
Earlier Versions of Adobe ColdFusion installed?
ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS <ENTER> TO ACCEPT THE DEFAULT: 2 (No)
Configure Webserver: 1 (Add Web Server Configuration)
Select "Apache" 1
Directory: /etc/apache2
File: /usr/sbin/apache2
File: /etc/init.d/apache2
Choice: 4 (Continue with installation)
Directory: (DEFAULT: /etc/htdocs): /var/www
User Name: (DEFAULT: nobody): <ENTER>
Password: <Default Development Password>
Enable RDSĀ  (Y/N): Y
Password: <Your Password>
PRESS <ENTER> TO CONTINUE: <ENTER>

Time for a cup of coffee ...

Press Enter to exit the installer: <ENTER>

3. Create an init script:

On Suse or Redhat you can use <pre>/opt/jrun4/bin/cf-init.sh install<pre> to create an init script but on Ubuntu or Debian you have to create your own script:

vim /etc/init.d/coldfusion8multi
#!/bin/sh
# MultiServer cfusion instance Init-Script

CF_DIR="/opt/jrun4"

cfstart() {
echo "The ColdFusion 8 server is starting up and will be available shortly."
nohup $CF_DIR/bin/jrun -start cfusion > $CF_DIR/logs/cfusion-event.log &
echo "======================================================================"
echo "ColdFusion 8 has been started."
echo "ColdFusion 8 will write logs to $CF_DIR/logs/cfusion-event.log"
echo "======================================================================"
}

cfstop() {
echo "Stopping ColdFusion 8, please wait"
nohup $CF_DIR/bin/jrun -stop cfusion
echo "ColdFusion 8 has been stopped"
}

case $1 in
    start)
        cfstart
    ;;
    stop)
        cfstop
    ;;
    restart)
        cfstop

    cfstart
    ;;
esac

exit 0

Install the init script:

update-rc.d coldfusion8multi defaults

Start the coldfusion server:

/etc/init.d/coldfusion8multi start

Setting up apache connector:

/opt/jrun4/bin/cf-connectors.sh

This will install and configurate the “mod_jrun22” for the apache webserver. (/etc/apache2/httpd.conf)

# JRun Settings
LoadModule jrun_module /opt/jrun4/lib/wsconfig/1/mod_jrun22.so
<IfModule mod_jrun22.c>
    JRunConfig Verbose false
    JRunConfig Apialloc false
    JRunConfig Ignoresuffixmap false
    JRunConfig Serverstore /opt/jrun4/lib/wsconfig/1/jrunserver.store
    JRunConfig Bootstrap 127.0.0.1:51020
    #JRunConfig Errorurl url <optionally redirect to this URL on errors>
    #JRunConfig ProxyRetryInterval 600 <number of seconds to wait before trying to reconnect to unreachable clustered server>
    #JRunConfig ConnectTimeout 15 <number of seconds to wait on a socket connect to a jrun server>
    #JRunConfig RecvTimeout 300 <number of seconds to wait on a socket receive to a jrun server>
    #JRunConfig SendTimeout 15 <number of seconds to wait on a socket send to a jrun server>
    AddHandler jrun-handler .jsp .jws .cfm .cfml .cfc .cfr .cfswf
</IfModule>

Restart the apache webserver:

/etc/init.d/apache2 restart

Now you can open the coldfusion administrator:

http://<SERVER>/CFIDE/administrator/index.cfm

Complete the installation in the coldfusion administrator.

4. Configurate an new coldfusion instance and virtual host:

First you have to create a new instance with the “Instance Manager”. Open the coldfusion administrator and select “Enterprise Manager” and choose “Instance Manager”. The next step is to select “Add New Instance” and enter a “Server Name” for your new cf instance “webapp1” for example and press “Submit”.

Jrun creates a new server directory “/opt/jrun4/servers/webapp1” and starts the instance. In the “Instance Manager” you can see the new instance and the HTTP-Port “8301” for example. Now you can access the coldfusion administrator of the instance with: “http://<SERVER>:8301/CFIDE/administrator/index.cfm”

The document root is in “/opt/jrun4/servers/webapp1/cfusion.ear/cfusion.war/”.

You can create a simple test file:

vim /opt/jrun4/servers/webapp1/cfusion.ear/cfusion.war/test.cfm
<h2>Test</h2>
<cfset test="Hello World">
<cfoutput>#test#</cfoutput>

You can open the Test-script with “http://<SERVER>:8301/test.cfm”.

Now create a new virtual host “webapp1”.

vim /etc/apache2/sites-available/webapp1
<VirtualHost *>
    ServerName www.testsrv.local

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

    DocumentRoot /opt/jrun4/servers/webapp1/cfusion.ear/cfusion.war/
    <Directory /opt/jrun4/servers/webapp1/cfusion.ear/cfusion.war/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>

    ErrorLog /var/log/apache2/error.log
    CustomLog /var/log/apache2/access.log combined
</VirtualHost>

Note: Very important is that line “JRunConfig Bootstrap 127.0.0.1:51000”. Foreach multiserver instance coldfusion creates an own port for the “JRunProxyService”. This port is defined in the “jrun.xml” of the instance.

vim /opt/jrun4/servers/webapp1/SERVER-INF/jrun.xml
...
<service class="jrun.servlet.jrpp.JRunProxyService" name="ProxyService">
...
<attribute name="port">51000</attribute>
<attribute name="deactivated">false</attribute>
...
</service>
...

Now install the new virtual host:

a2ensite webapp1

and reload the apache webserver:

/etc/init.d/apache2 reload

Now you can access your test script with “http://www.testsrv.local/test.cfm”.

And you can access the coldfusion administrator with “http://www.testsrv.local/CFIDE/administrator/index.cfm”.

You should do some extra configurations like restrict the access to CFIDE with an additional “.htaccess” file, restrict the directory listing and some other apache security settings.

5. Modify init script:

The coldfusion server does’t start the instance on startup. You have to add all instances to your init script. Here is an modified version for “webapp1”:

#!/bin/sh
# MultiServer cfusion instance Init-Script

CF_DIR="/opt/jrun4"

cfstart() {
echo "The ColdFusion 8 server is starting up and will be available shortly."
nohup $CF_DIR/bin/jrun -start cfusion > $CF_DIR/logs/cfusion-event.log &
nohup $CF_DIR/bin/jrun -start -childVM webapp1 > $CF_DIR/servers/webapp1/cfusion.ear/cfusion.war/WEB-INF/cfusion/logs/cfusion-event.log &
echo "======================================================================"
echo "ColdFusion 8 has been started."
echo "ColdFusion 8 will write logs to $CF_DIR/logs/cfusion-event.log"
echo "======================================================================"
}

cfstop() {
    echo "Stopping ColdFusion 8, please wait"
    nohup $CF_DIR/bin/jrun -stop cfusion
    nohup $CF_DIR/bin/jrun -stop -childVM webapp1
    echo "ColdFusion 8 has been stopped"
}

case $1 in
    start)
        cfstart
    ;;
    stop)
        cfstop
    ;;
    restart)
        cfstop
        sleep 20
        cfstart
    ;;
esac

exit 0

Note: You can create an own init script for each instance, too. You don’t need the main cfusion application to run the instances.

, , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.