Commit 5ee6639c authored by Mike Hibler's avatar Mike Hibler

Insane hacks to get apache13 working

parent 19d90d3f
......@@ -11,6 +11,15 @@ TESTBED_SRCDIR = @top_srcdir@
OBJDIR = ..
SUBDIR = apache
SYSTEM := $(shell uname -s)
ifeq ($(SYSTEM),FreeBSD)
FBSDREL := $(shell uname -r | sed -e 's/\([^-][^-]*\)-.*/\1/')
FBSDMAJ := $(basename $(FBSDREL))
ifeq ($(FBSDMAJ),7)
SCRIPT_HACK = 1
endif
endif
include $(OBJDIR)/Makeconf
CONFIG_FILES = httpd.conf httpd.conf-ops
......@@ -42,10 +51,26 @@ httpd.conf.fixed: httpd.conf
echo "Updated httpd.conf"; \
fi
install: httpd.conf.fixed
#
# XXX another woeful hack. There appears to be a well-documented problem
# with Apache and PHP4, where loading PHP with certain extensions will cause
# Apache to crash immediately. However, if you start it without PHP and then
# use apachectl to restart it *with* PHP, all is well. Go figure...
# We install this script which accomodates that...ahem, "behavior."
# Since we have only seen this on FBSD7, we only do it there.
#
script-install: apache-emulab
ifeq ($(SCRIPT_HACK),1)
@if [ -f /usr/local/etc/rc.d/apache -a ! -f /usr/local/etc/rc.d/.apache.real ]; then \
mv /usr/local/etc/rc.d/apache /usr/local/etc/rc.d/.apache.real; \
fi
$(INSTALL) -m 755 $(SRCDIR)/apache-emulab /usr/local/etc/rc.d/apache-emulab
install: script-install httpd.conf.fixed
$(INSTALL_DATA) httpd.conf.fixed $(INSTALL_APACHE_CONFIG)/httpd.conf
endif
control-install: httpd.conf-ops
control-install: script-install httpd.conf-ops
$(INSTALL_DATA) httpd.conf-ops $(INSTALL_APACHE_CONFIG)/httpd.conf
clean:
#!/bin/sh
# PROVIDE: apache
# REQUIRE: DAEMON
# BEFORE: LOGIN
# KEYWORD: shutdown
# if real apache startup file hasn't been moved, we do nothing
if [ -f /usr/local/etc/rc.d/apache -o ! -f /usr/local/etc/rc.d/.apache.real ]
then
return 0
fi
ARGS=$*
CFFILE=/usr/local/etc/apache/httpd.conf
command=/usr/local/sbin/httpd
pidfile=/var/run/httpd.pid
. /etc/rc.subr
#
# It seems to be well documented that some combinations of apache and PHP
# extensions result in immediate crash of the server. There is also a
# work around that involves "apachectl restart". So if apache fails to
# start up, we enact the hack.
#
case $1 in
*start)
# (re)start it
/usr/local/etc/rc.d/.apache.real $ARGS
# give it time to crash
sleep 2
# still running? all done
rc_pid=$(check_pidfile $pidfile $command)
if [ -n "$rc_pid" ]; then
return 0
fi
# otherwise tweak the config file and start again
echo "Apache did not start; trying PHP restart hack..."
rm -f $CFFILE.orig
sed -i .orig -e '/^LoadModule php4_module/s/^/#/' -e '/^AddModule mod_php4.c/s/^/#/' $CFFILE || return 1
/usr/local/etc/rc.d/.apache.real $ARGS
sleep 2
# still not running? we have bigger problems
rc_pid=$(check_pidfile $pidfile $command)
if [ -z "$rc_pid" ]; then
mv $CFFILE.orig $CFFILE
return 1
fi
# otherwise restore config and use apachectl to restart
mv $CFFILE.orig $CFFILE
/usr/local/sbin/apachectl restart
;;
*)
/usr/local/etc/rc.d/.apache.real $ARGS
;;
esac
return $?
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment