Home | Projects | Contact Me

Starting ColdFusion on Boot with Ubuntu

Since my recent move to Linux I have been slowly but surely getting my development environment set up. In Ubuntu 8.10 it is fairly painless to get an ACME server up and running quickly. Apache, MySQL, and Eclipse are easily installed through package managers or using CLI tools in the shell. ColdFusion is easy enough to install as well, the main issue I had during my installation was the fact that ColdFusion did not start when the system booted using the install scripts installed by Adobe. Apparently the installer only likes RedHat and SuSE Linux so I had to do a little poking around to get it starting up automatically.

I will be the first to admit I currently know just enough about Linux to be dangerous. At any rate, here is how I got it working in case it may help someone else. If any gurus out there see me doing someone that is obviously wrong, please let me know!

First I created the scripts in /etc/init.d/ that will be used to start and stop the ColdFusion server. Using vi (running as root of course) I created coldfusion_start.sh and coldfusion_stop.sh to start and stop the ColdFusion server, respectively. The files short and to the point. As an example, here is my coldfusion_start.sh script:

#!/bin/sh -e
/opt/coldfusion8/bin/coldfusion start

The coldfusion_stop.sh file is almost identical except we send the stop parameter instead of start.

#!/bin/sh -e
/opt/coldfusion8/bin/coldfusion stop

After getting the scripts setup, we need to be able to execute them which is easy enough to do with a "sudo chmod +x /etc/init.d/coldfusion_start.sh" and "sudo chmod +x /etc/init.d/coldfusion_stop.sh" without the quotes, of course.

Now here is where my process gets a little less than scientific. Starting with /etc/rc0.d/ and working my way to /etc/rc5.d/ I looked for any symbolic links that had the Apache daemon starting or stopping. If Apache was starting I created a new symbolic link to my coldfusion_start.sh script and if Apache was stopping I created a symbolic link to the coldfusion_stop.sh script. I always made sure that ColdFusion was started or stopped after the Apache service.

For example, the link to kill ColdFusion in /etc/rc0.d/: sudo ln -s /etc/init.d/coldfusion_stop.sh /etc/rc0.d/K90coldfusion

The link to start ColdFusion in /etc/rc3.d/: sudo ln -s /etc/init.d/coldfusion_start.sh /etc/rc3.d/S95coldfusion

In retrospect, it may make more sense to stop the ColdFusion server before the Apache server is stopped but currently I have it starting and stopping after Apache. However, everything appears to be running smoothly.

Comments
Adrian J. Moreno's Gravatar Thanks for the info Shane. I added a link to this post in my ACME Guide for Ubuntu.
# Posted By Adrian J. Moreno | 11/13/08 11:06 AM
Steven Erat's Gravatar So what happened exactly when you tried using the {cf_root}/bin/cf-init.sh script to configure ColdFusion to start on boot? You noted that "the installer only likes RedHat and SuSE Linux".
# Posted By Steven Erat | 11/13/08 11:22 AM
Shane Zehnder's Gravatar Running cf-init.sh in /opt/coldfusion8/bin exits with the following:

Sorry, only Red Hat and SuSE Linux are supported.
# Posted By Shane Zehnder | 11/13/08 11:33 AM
Shane Zehnder's Gravatar @Adrian: Thanks for the link!
# Posted By Shane Zehnder | 11/13/08 11:37 AM
Sonny's Gravatar Hey guys,

I found this article and it got me on the right direction. I did mine a little different but it works great for me. I'm running Ubuntu 8.10 with Coldfusion 8. As root I did:

1) I created a script just like you did in /etc/init.d called coldfusion with these contents

#!/bin/sh -e
/opt/coldfusion8/bin/coldfusion $1

2) chmod +x coldfusion
3) I did a listing of /etc/rc5.d to get the system number for Apache. In my case it was 91.

ls /etc/rc5.d

4) From here I was a bit of a loss so I checked the README and it pointed me to the Debian systems guide. That's where I discovered this next little gem of a command.

update-rc.d -n coldfusion defaults 92

5) The -n (stands for "not really") shows you what the command will do but it won't actually do anything. If all goes well, you should see several links for stopping the services created in run level 016 and start up scripts for the remaining run levels. I chose 92 as my system number because they are executed in ascending order and I wanted coldfusion to start after Apache. Using the defaults command creates start and stop scripts (links actually). So, if all went well, execute this command (same as above just no -n). The init command will actually pass the start and stop parameter to your script so no need for two.

update-rc.d coldfusion defaults 92

6) I then executed this to make sure it all worked liked I was hoping. Obviously don't do this on a production box!

shutdown -r now

I saw the message for coldfusion shutdown and when the system came up, right after Apache, I saw my startup messages for Coldfusion! Thanks for the lead Shane and I hop others find my information useful.
# Posted By Sonny | 2/22/09 3:58 PM
Paul's Gravatar Very helpful thanks. The same steps worked for me creating the railo auto startup scripts. Thanks to Sonny who explained how to find the correct number ( 92 ) aswell.
# Posted By Paul | 6/9/09 9:38 AM
Layout: Shane Zehnder ::: BlogCFC was created by Raymond Camden. ::: This blog is running version 5.9.