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

Very happy I can comment here!

Best wishes for this year.

Interesting thing!

That's awesome! I can't wait to get into it.

ghd hair straighteners catch people's eyes.people expect to see new items of ghd hair straighteners, while the classic items are still hot, like ghd purple?ghd straighteners enjoy good reputation, pink ghd is a hot style of ghd hair straighteners.

Once I heard one word that is everyone should have a good pair of shoes because of this pair of good shoes will take you to the best place!I think the timberland boots and ugg boots will be the best friend of you in the future.Why?!The real cause is that the authentic waterproof boots of timberland and the beautiful ugg boots not only can keep your feet warm and comfrotable but also can let you more dazzling.You can have a try!To have a appropriate watch can reflect your position and makes you more attractive!We have many swiss watches and mens womens watches for you choose!

welcome to www.bootsness.com,www.dressugg.com,www.watchesch.com,www.wristwatchlady.com

100% authentic sheepskin for unrivalled comfort,Durable double stitched construction, Zero cost exchange,No additional duties or import fees,Worldwide trackable shipping with full-cover insurance,Lushiously thick inner fleece for extreme toastiness,All boots on www.footwearmbt.com are free shipping 7 days delivery!footwearmbt.com

Buy discount timberland shoes with a price guarantee and top rated customer service.You can compare multiple cheap timberland shoes styles.cheap anddiscount timberland boots and timberland work boots(footwear).If you like buying timberland boots online,such as buy timberland boots mbt4sale,you will like our mbt4sale footwear shop service.

MBT health shoe is a pair of shoes healthy.Cheap shoes MBT for you,Of course you can enjoy certain privileges.On the contrary,Christian Louboutin heels,Trademark red soles of Christian Louboutin's bright give an instant stamp of fashion excellence,is the top heels for popular women.There is no doubt that the Christian Louboutin Shoes are designed for the women ,Christian Louboutin shoes can make the women more attractive and elegant.

Welcome to come to www.shoetimberland.com

Converse shoes are the most stylish new shoes in 2010! 2009 and 2010 have brought many new shoes styles and this is true for sneakers of all types and shoes found on sale at outlet prices as well you can enjoy free shipping worldwide,1 week delivery to your door, and sometimes you can get a special discount from our company by email! Our customers are always satisfied with such kind of shoes and Ed hardy handbags and our high service!Best choice and more easier, convenient and fast to do business with us.

welcome to www.outletconverse.com

nike shoes are the most stylish new shoes in 2010! 2009 and 2010 have brought many new shoes styles and this is true for boots of all types and shoes found on sale at outlet prices as well you can enjoy free shipping worldwide,1 week delivery to your door, and sometimes you can get a special discount from our company by email! Our customers are always satisfied with such kind of shoes and our high service!Best choice and more easier, convenient and fast to do business with us.welcome to www.timberlandonline.net

We cooperate with some strong company specialized factories and express. At the same time, we can send too.So own warehouse products immediately. Best quality, fast Delivered excellent service is a service principle of our company. We strongly welcome the new and old customers to cooperate with our us.Hope tomorrow will be more beautiful. Our company usually keeps updating new products.Kindly let us know your interest, you will receive immediate response. Choosing your product. You can either choose a featured product from the homepage or go to a category page (like jerseys,ugg shoes,ugg boots) and click on a product. We provide many advantages as below *free shipping *low price *professional customers service *secure processing,plus) *if you don't like what you've received, simply return it! welcome to www.jerseymiss.com

It's so lucky for me to find your blog! So shocking and great! Just one suggestion: It will be better and easier to follow.

http://www.airjordanshoe23.com/

http://www.sneakershoebay.com/

http://www.christianlouboutinsaling.com/

ed hardy t shirts,

discount uggs boots or

cheap ghd straighteners,

christian louboutin boots and 

discount ugg boots as well as 

p90x workout,

air jordan shoes,cheap authentic nfl jerseys,

chi hair straightener t shirts. i think more and more people would comr to read your blogs.

Wow, thanks for the insightful post. I look forward to reading more from you.