Archive - Originally posted on "The Horse's Mouth" - 2006-10-28 10:17:23 - Graham Ellis
I've just completed a course covering the installation and configuration of Apache httpd, Apache Tomcat and MySQL. Complete with a demonstration that has the newly installed systems visited from various browsers, talking to httpd, which talks on to Tomcat, which talks on in turn to MySQL. The MySQL responses are handled by the Servlets and JSPs running on Tomcat, and returned via the masking Apache httpd that's used for the majority of the web site on the chosen domain. This might all sound very complicated, but it's actually what happens on so many web sites which, no doubt, is why there's such a call for our deployment course.
And what happens when the server is restarted? Well - you had better make sure that all the services start up properly, hadn't you?
On a Linux / Unix system, you can add scripts that are to be run during system startup, typically to start server processes known as daemons, to the directory /etc/init.d. These scripts should understand (as a minium) a command line parameter "start" to do everything needed to start the service, and "stop" to do everything needed to stop the service. And it's no coincidence that modern versions of apache httpd ship with a utility called apachectl that accepts these argument, apache tomcat ships with catalina.sh which also accepts these parameters, and there'a a utility script in mysql's script directory that does the same thing for that daemon.
So it that all you need to know? Not quite! Just placing the scripts into /etc/init.d does NOT cause them to be run; on system startup, when entering full multi-user mode (run state 3) or multiuser mode with windows (run state 5), Linux / unix go through the directory /etc/rc3.d (or rc5.d, or /etc/init.d/rc3.d etc ... depending on the Linux flavour) and run every file starting with the letter S in asciibetic order. Now - you do not want to copy the scripts from init.d to those other directories so the whole thing is set up by filling the "rc" directories with a series of symbolic links back to /etc/init.d. That way, you can turn daemons on and off just by adding and removing links - a very neat scheme indeed.
Here's an example of such a link in /etc/init.d/rc3.d (on a SuSE system)