3
# apache2 This init.d script is used to start apache2.
4
# It basically just calls apache2ctl.
6
ENV="env -i LANG=C PATH=/usr/local/bin:/usr/bin:/bin"
8
#[ `ls -1 /etc/apache2/sites-enabled/ | wc -l | sed -e 's/ *//;'` -eq 0 ] && \
9
#echo "You haven't enabled any sites yet, so I'm not starting apache2." && \
10
#echo "To add and enable a host, use addhost and enhost." && exit 0
12
#edit /etc/default/apache2 to change this.
16
if [ -x /usr/sbin/apache2 ] ; then
22
. /lib/lsb/init-functions
24
test -f /etc/default/rcS && . /etc/default/rcS
25
test -f /etc/default/apache2 && . /etc/default/apache2
26
if [ "$NO_START" != "0" ]; then
27
[ "$VERBOSE" != no ] && log_warning_msg "Not starting apache2 - edit /etc/default/apache2 and change NO_START to be 0.";
31
APACHE2="$ENV /usr/sbin/apache2"
32
APACHE2CTL="$ENV /usr/sbin/apache2ctl"
35
if `apache2 -t > /dev/null 2>&1`; then
36
# if the config is ok than we just stop normaly
39
# if we are here something is broken and we need to try
40
# to exit as nice and clean as possible
42
# if pidof is null for some reasons the script exits automagically
43
# classified as good/unknown feature
48
# let's try to find the pid file
49
# apache2 allows more than PidFile entry in the config but only
50
# the last found in the config is used
51
for PFILE in `grep ^PidFile /etc/apache2/* -r | awk '{print $2}'`; do
52
if [ -e $PFILE ]; then
57
# if there is a pid we need to verify that belongs to apache2
60
if [ "$i" = "$PID" ]; then
61
# in this case the pid stored in the
62
# pidfile matches one of the pidof apache
63
# so a simple kill will make it
68
if [ $REALPID = 1 ]; then
69
# in this case it is everything nice and dandy
73
# this is the worst situation... just kill all of them
81
# Stupid hack to keep lintian happy. (Warrk! Stupidhack!).
84
[ -f /etc/apache2/httpd.conf ] || touch /etc/apache2/httpd.conf
85
#ssl_scache shouldn't be here if we're just starting up.
86
[ -f /var/run/apache2/ssl_scache ] && rm /var/run/apache2/ssl_scache
87
log_begin_msg "Starting web server (Apache2)..."
88
if $APACHE2 -k start -DSSL; then
95
log_begin_msg "Stopping web server (Apache2)..."
103
log_begin_msg "Reloading web server config..."
104
if $APACHE2CTL graceful $2 ; then
111
log_begin_msg "Restarting web server (Apache2)..."
112
if $APACHE2CTL restart; then
119
log_begin_msg "Forcing reload of web server (Apache2)..."
120
if ! apache_stop; then
124
if $APACHE2CTL start; then
131
log_success_msg "Usage: /etc/init.d/apache2 start|stop|restart|reload|force-reload"