Automatically start ColdFusion at boot on Ubuntu Linux (but not 8.04)


Quite a few months ago I did a blog post about starting ColdFusion on boot with Ubuntu Linux. When I originally wrote the post I did put a disclaimer on there that I was indeed new to Linux and there was probably a better way to do what I was attempting to do. I was right.

There is a very easy way to accomplish this in three steps and it does not require editing your system files or going through all the run levels and trying to figure out where to start and stop ColdFusion.

The first thing you need to do is make sure the chkconfig utility is installed on your system. I do not believe it is installed by default on Ubuntu distributions, but that is easy enough to remedy:

sudo apt-get install chkconfig

Next we need to copy our generated coldfusion script to /etc/init.d:

sudo cp /opt/coldfusionX/bin/coldfusion /etc/init.d

At the top of the file ColdFusion made for us are some special directives for the chkconfig utility. Chkconfig will look for these and automatically set where ColdFusion needs to be stopped and started. It looks something like this:

#!/bin/sh

# chkconfig: 345 90 14
# description: starts the ColdFusion MX server

Finally, run the chkconfig utility to add ColdFusion service to the list of services run at boot:

sudo chkconfig --add coldfusion

Enjoy.

I was later informed that these instructions do not work on Ubuntu 8.04.  A user found a way around the issue:

Found it and it works!

Create a link to coldfusion in the init.d folder:

sudo ln -s /opt/coldfusion8/bin/coldfusion /etc/init.d/coldfusion

Run update-rc.d:

sudo update-rc.d coldfusion defaults

Easy-Peasy! Even if I have no idea what running update-rc.d actually does…

Advertisements

About Robert Zehnder

Web application developer specializing in ColdFusion/Railo and Open Source development.

Posted on November 13, 2009, in ColdFusion, Linux. Bookmark the permalink. 10 Comments.

  1. I’m working on setting up a VM with CF9 on Ubuntu and I simply added the CF9 startup to /etc/rc.local:

    ./opt/coldfusion9/bin/coldfusion start

  2. John di Stefano

    Jim Priest :
    I’m working on setting up a VM with CF9 on Ubuntu and I simply added the CF9 startup to /etc/rc.local:
    ./opt/coldfusion9/bin/coldfusion start

    That might work if you have that file …….

  3. dont forget
    sudo chmod +x /etc/init.d/coldfusion

  4. On the latest versions of Ubuntu and Debian, you have to use update-rc.d which serves the same function as chkconfig using a different configuration.

    This requires to modify the coldfusion script (the sed command bellow), for more info, checkout:
    http://wiki.debian.org/LSBInitScripts

    The commands (as root) and output is:
    # ln -s /opt/coldfusion9/bin/coldfusion /etc/init.d/coldfusion
    # sed -i -f – /etc/init.d/coldfusion < ../init.d/coldfusion
    /etc/rc1.d/K20coldfusion -> ../init.d/coldfusion
    /etc/rc6.d/K20coldfusion -> ../init.d/coldfusion
    /etc/rc2.d/S20coldfusion -> ../init.d/coldfusion
    /etc/rc3.d/S20coldfusion -> ../init.d/coldfusion
    /etc/rc4.d/S20coldfusion -> ../init.d/coldfusion
    /etc/rc5.d/S20coldfusion -> ../init.d/coldfusion

  5. My sed command and the beginning of update-rc.d, have been swallowed. Anyway, you need to insert after line 1 for the coldfusion startup script the following lines (using sed or your preferred interactive editor):

    ### BEGIN INIT INFO
    # Provides: coldfusion
    # Required-Start: apache2 mysql
    # Required-Stop: apache2 mysql
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: Starts Coldfusion at boot time
    # Description: ColdFusion Server
    ### END INIT INFO

    Then you need to run update-rc.d:
    # update-rc.d coldfusion defaults
    Adding system startup for /etc/init.d/coldfusion …
    /etc/rc0.d/K20coldfusion -> ../init.d/coldfusion
    /etc/rc1.d/K20coldfusion -> ../init.d/coldfusion
    /etc/rc6.d/K20coldfusion -> ../init.d/coldfusion
    /etc/rc2.d/S20coldfusion -> ../init.d/coldfusion
    /etc/rc3.d/S20coldfusion -> ../init.d/coldfusion
    /etc/rc4.d/S20coldfusion -> ../init.d/coldfusion
    /etc/rc5.d/S20coldfusion -> ../init.d/coldfusion

  6. Many Thanks for providing easy solution! Great job!

  7. A debt of thanks from me to you — your wisdom prevailed after several other approaches failed.

    THANK YOU!

  8. Many thanks!! Wonderful to find such an easy fix to start on boot after researching this for an hour.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: