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…
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 …….
I tried it with cf9 and it didn’t work.
I then used your part fort 8.04 and it worked a treat.
Thanks
dont forget
sudo chmod +x /etc/init.d/coldfusion
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
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
Thank you for the update! I appreciate it and I am sure others will as well.
Many Thanks for providing easy solution! Great job!
A debt of thanks from me to you — your wisdom prevailed after several other approaches failed.
THANK YOU!