Apache and ColdFusion Startup Scripts for Ubuntu

The last step for my Ubuntu setup (from a development standpoint anyway--I have other stuff to do like get my MP3 player working) was to create startup scripts for Apache and CF since I don't want to start that stuff manually every time I boot my machine.



First a quick plug for Dave Shuck's excellent post on installing Apache 2 and CF on Ubuntu. The only change I made to his instructions was to create a symlink to the CF administrator files instead of copying them over into Apache's docroot.



For the startup scripts I consulted a Linux administrator friend. If you're just getting into Linux, make friends with a Linux administrator immediately. :-) The apache one turned out to be quite simple--just create two symlinks to the apache command as follows, in the /etc/rc2.d directory:



ln -s /usr/local/apache2/bin/apachectl S91httpd

ln -s /usr/local/apache2/bin/apachectl K91httpd



To translate, that tells the OS to run 'apachectl start' on boot, and 'apachectl stop' on shutdown, based on the S and K before the two links. The number 91 specifies the order in which things are loaded. As for the rc2.d, the scripts in this directory are run at runlevel 2 (you can learn more about runlevel here).



Basically, due to the fact that these symlinks are put in the rc2.d directory, the OS scans and runs all the "S"-prefixed scripts at startup, and all the "K"-prefixed scripts at shutdown, but it does this by tacking "start" and "stop" to the end of the command pointed to in the link.



Since CF's startup command is a bit different, this was trickier, which is why it's handy to have a Linux guru you can call on for help. Tacking start and stop onto the jrun command won't quite suffice so a custom script is needed. The script looks like this:



#!/bin/bash

case "$1" in

    start)

        /opt/jrun4/bin/jrun -start cfusion

        ;;

    stop)

        /opt/jrun4/bin/jrun -stop cfusion

        ;;

esac



You can save this script anywhere you want, and similarly to the above, you just create a symlink, but this time to the script file itself. In my case I called my script file 'cfusion_startup.sh' and stored it in the /opt/jrun4/bin directory, so the symlinks look like this:



ln -s /opt/jrun4/bin/cfusion_startup.sh S92cfusion

ln -s /opt/jrun4/bin/cfusion_startup.sh K92cfusion



Now I don't know for sure, but this may still tack "start" and "stop" on the end of things, but it seems to work anyway. I put the number 92 on these so that CF will start and stop right after apache does.



Hope that helps someone else. As always YMMV but this works for me. I'm by no means a Linux guru at this level (hence another thanks to my Linux expert friend), so if any of you have other ways of doing this, I'd love to see some other approaches.

Comments

Hi Matt,

My initial comments to your post ran on a bit, so I've posted as my own blog entry here:

http://www.talkingtree.com/blog/index.cfm/2006/10/20/Saving-costs-in-Linux-environments-while-still-using-a-stable-server-platform-for-ColdFusion

The commands are missing the start and stop params.

This:

ln -s /usr/local/apache2/bin/apachectl S91httpd

To That:

ln -s "/usr/local/apache2/bin/apachectl start" S91httpd

-And-

This:

ln -s /usr/local/apache2/bin/apachectl K91httpd

To That:

ln -s "/usr/local/apache2/bin/apachectl stop" K91httpd

Also, don't forget you have to give the custom script fix execute permissions or it won't work. I used WinSCP to create the file, and by default it does not give new files execute permission. Banged my head against that one for a few minutes! Hope it helps someone. For the life of me I can't figure out why the ColdFusion installer does not create this by default. Either it's an oversight/bug, or it's just plain lame.

It's often desirable to force users to access things like webmail via https. This can be accomplished with mod_rewrite.

First you'll have to enable the module

In reply to the post made by John, that is wrong.

When you link anything as SnnFilename, normal startup calls filename with a parameter of 'start' and similarly with Knnfilename appends 'stop'

I also don't believe that you can make a symlink to a string. It has to be to a filename.

Thanks for this post. Be careful when copying and pasting the coldfusion startup script - the double quotes ended up being full-stops in my script when I pasted it into vi. I didn't spot it until after much head-scratching!

Thanks for this document i`m search many days in the world wide web,but now i found this information on your site.

Good Work!

FWIW, I ran

ln -s /opt/coldfusion8/bin/coldfusion coldfusion

in /etc/init.d

and then used update-rc.d coldfusion. Works perfectly, and when it becomes time to update to CF9 all I should have to do is update that symlink.

I gotta say, I'm *really* enjoying getting back into a *nix environment.

Good quality Yellow Ugg. Didn't realize ugg boots mayfaire were specific for winter activities, have worked very well, so Ugg Classic Cardy will be you best choice.

UGG Locarno Boots don't come cheaper either the original ugg 5389 boots Australia brand which hit Ireland circa 2006, costs 220 and upwards, with new styles like the Ugg Sundance gracing the shops this year.

With the Christmas is coming,there are big sales promotions on our website,replica rolexand rolex watche on our site are lower than ever,you may be intersting in fake rolex or replica watch,rolex replicas ,come on to choose your favorate goods!

Thank you.Hot Shoes Cheap Jordan shoes michael jordan shoes and are on sale-Free shipping.

thanks

good

nice