[HOME] [BASH] [Window Managers]

LAMP for web developers

#!/bin/bash
#
##  Manually start|stop LAMP in Debian (Lenny)
#
## This script is an alternative to those who like me install apache
## and mysql only for web development use and for system security and
## performance reasons don't like them running all the time and open
## to the internet.

if [ "$(whoami)" != "root" ] ; then
	echo "You must be root"
	exit 1
fi

args=1
if [ $# -ne $args ] ; then
	echo "Usage: `basename $0` {start|stop}"
	exit 1
fi

## By default Debian load apache and mysql at boot time (it may ask
## you like Slackware does).  On each apache or mysql upgrade debian
## writes the init links again.  That's why it is convenient doing
## this first:
ls /etc/rc* | grep -e S..apache2 -e S..mysql >/dev/null	&& {
	update-rc.d -f apache2 remove
	for i in /etc/init.d/mysql* ; do
		update-rc.d -f `basename $i` remove
	done
}

## Closing apache to internet (This works only if iptables is
## installed and your kernel supports filtering):
# if [ -x /sbin/iptables ] ; then
# 	iptables -A INPUT -p tcp --dport 80 -j DROP
# 	iptables -A OUTPUT -p tcp --sport 80 -j DROP
# fi

## This will read user argument and start or stop servers.
/etc/init.d/apache2 $1
for i in /etc/init.d/mysql* ; do
	$i $1
done
exit 0

## End wserver
<= Prev Next =>


[HOME] [BASH] [Window Managers]

You can mail me to eloi at roquesor.com.