My knowledge is limited, but I try to do my best:
When you enter a runlevel, the scripts in the corresponding directory are run sequentially. Every service should have two symlinks, one named S##service, the other K##service. When you enter the runlevel, the 'S' scripts are invoked, leaving it, the 'K' scripts run. Since both links point to the same script, the actual work is done by this script: it checks if the service is running (/etc/rc.status) and then it starts or stops the service accordingly. You can also run these scripts from command line, by passing the variable 'start|stop|restart'.
So a quick answer to your question is: the service is started from the script /etc/init.d/rc3.d/S##apache2 and shutdown with /etc/init.d/rc3.d/K##apache2 when you leave the runlevel. The number defines the order in which scripts are being started/shut-down.
EDIT: There is a very helpful README in /etc/init.d. From this I have learned that the script /etc/init.d/rc does the actual work (finding out if a runlevel has to be started or stopped, and in which runlevel it has to be started/stopped).
Last edited by abisko00; 04-05-2005 at 09:30 AM.