Executing Microsoft SQL Server Stored Procedure from PHP on Linux - Installing the Apache Web Server, Cont'd
(Page 4 of 9 )
In a real production environment, we would like Apache running as a service, meaning that whenever our machine starts-up, these services will startup automatically. Copy and paste the following script and save it as httpd in the /etc/init.d folder.
#!/bin/bash
#
# Startup script for the Apache Web Server
#
# chkconfig: - 85 15
# description: Apache is a World Wide Web server. It is used to serve \
# HTML files and CGI.
# processname: httpd
# pidfile: /var/run/httpd.pid
# config: /usr/local/apache2/conf/httpd.conf
# Source function library.
. /etc/rc.d/init.d/functions
# This will prevent initlog from swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""
# Path to the Apachectl script, server binary, and short-form for messages.
apachectl=/usr/local/apache2/bin/apachectl
httpd=/usr/local/apache2/bin/httpd
prog=httpd
RETVAL=0
# The semantics of these two functions differ from the way Apachectl does
# things -- attempting to start while running is a failure, and shutdown
# when not running is also a failure. So we just do it the way init scripts
# are expected to behave here.
start() {
echo -n $"Starting $prog: "
daemon $httpd $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/httpd
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc $httpd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/httpd /var/run/httpd.pid
}
reload() {
echo -n $"Reloading $prog: "
check13 || exit 1
killproc $httpd -HUP
RETVAL=$?
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $httpd
RETVAL=$?
;;
restart)
stop
start
;;
condrestart)
if [ -f /var/run/httpd.pid ] ; then
stop
start
fi
;;
reload)
reload
;;
graceful|help|configtest|fullstatus)
$Apachectl $@
RETVAL=$?
;;
*)
echo $"Usage: $prog {start | stop | restart | condrestart | reload | status | fullstatus | graceful | help | configtest}"
exit 1
esac
exit $RETVAL
Then issue the following command:
chkconfig httpd --level 345 on
This will set Apache to start on Linux level 3 4 and 5 automatically – (by default, Red Hat is running on level 5 with X windows, most production machines will choose level 3, without GUI).
Reboot the machine; you can test it in the browser, now Apache web server starts up automatically with the machine reboot.
Next: Installing FreeTDS >>
More PHP Articles
More By Jack Zhang