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
19
echo "No apache MPM package installed"
23
. /lib/lsb/init-functions
25
test -f /etc/default/rcS && . /etc/default/rcS
26
test -f /etc/default/apache2 && . /etc/default/apache2
27
if [ "$NO_START" != "0" -a "$1" != "stop" ]; then
28
[ "$VERBOSE" != no ] && log_warning_msg "Not starting apache2 - edit /etc/default/apache2 and change NO_START to be 0.";
32
APACHE2="$ENV /usr/sbin/apache2"
33
APACHE2CTL="$ENV /usr/sbin/apache2ctl"
36
# if pidof is null for some reasons the script exits automagically
37
# classified as good/unknown feature
38
PIDS=`pidof apache2` || true
42
# let's try to find the pid file
43
# apache2 allows more than PidFile entry in the config but only
44
# the last found in the config is used
45
for PFILE in `grep ^PidFile /etc/apache2/* -r | awk '{print $2}'`; do
46
if [ -e $PFILE ]; then
52
# if there is a pid we need to verify that belongs to apache2
55
if [ "$i" = "$PID" ]; then
56
# in this case the pid stored in the
57
# pidfile matches one of the pidof apache
58
# so a simple kill will make it
67
if `apache2 -t > /dev/null 2>&1`; then
68
# if the config is ok than we just stop normaly
71
# if we are here something is broken and we need to try
72
# to exit as nice and clean as possible
76
# in this case it is everything nice and dandy
79
elif [ "$(pidof apache2)" ]; then
80
if [ "$VERBOSE" != no ]; then
82
echo "You may still have some apache2 processes running. There are"
83
echo "processes named 'apache2' which do not match your pid file,"
84
echo "and in the name of safety, we've left them alone. Please review"
85
echo "the situation by hand."
92
# Stupid hack to keep lintian happy. (Warrk! Stupidhack!).
95
[ -f /etc/apache2/httpd.conf ] || touch /etc/apache2/httpd.conf
96
[ -d /var/run/apache2 ] || mkdir -p /var/run/apache2
97
[ -d /var/lock/apache2 ] || mkdir -p /var/lock/apache2
98
#ssl_scache shouldn't be here if we're just starting up.
99
[ -f /var/run/apache2/ssl_scache ] && rm -f /var/run/apache2/*ssl_scache*
100
log_begin_msg "Starting web server (apache2)..."
101
if $APACHE2CTL start; then
108
log_begin_msg "Stopping web server (apache2)..."
116
if ! $APACHE2CTL configtest > /dev/null 2>&1; then
117
$APACHE2CTL configtest || true
121
log_begin_msg "Reloading web server config..."
122
if pidof_apache; then
123
if $APACHE2CTL graceful $2 ; then
130
restart | force-reload)
131
log_begin_msg "Forcing reload of web server (apache2)..."
132
if ! apache_stop; then
136
if $APACHE2CTL start; then
143
log_success_msg "Usage: /etc/init.d/apache2 {start|stop|restart|reload|force-reload}"